dyb_dzo 0 Posted July 4, 2016 Share Posted July 4, 2016 I want to check if a note with a given name already exists: tell application "Evernote" if note named thisTitle exists then tell note named thisTitle to append html "<strong>exists</strong>" else set note1 to create note title thisTitle with text thisContent as string notebook "DAILY" assign tag "PDF" to note1 end if end tell But it gives me error: Evernote got an error: Can’t get note "[thisTitle]" How do i check if a note exists? Link to comment
Level 5* JMichaelTX 4,117 Posted July 5, 2016 Level 5* Share Posted July 5, 2016 On 7/4/2016 at 0:13 PM, dyb_dzo said: How do i check if a note exists? This script on my Github Gist should give you a good idea of how to do this: EN Mac Append Note OR Create New Note (AS).applescript Please let me know if you have any questions or issues. DISCLAIMER: • This script is provided for EDUCATIONAL PURPOSES ONLY • It has had very limited testing, and may contain errors & bugs • The user of this script assumes all risk and liability • This script does write to your Evernote account, so it is best to first test using a Test Account Link to comment
dyb_dzo 0 Posted July 6, 2016 Author Share Posted July 6, 2016 Your solution looks quite robust! It's probably too much for my needs but i see where it could be usefull. Thank you! It also opened my eyes for what i was doing wrong. Before your post i found out how to search for notes but that didn't work as well. My bit of code: _ set foundNote to get every note of notebook "DAILY" where its title is searchForThisTitle if foundNote is {} then –– create new note and do stuff with it else set myNote to item 1 of foundNote –– do stuff to the existing note _ I missed the part "item 1 of" – instead of picking an item from the foundNote i was just referencing to the found set. My question was derived from "if note named thisTitle exists then" but it seems like i should utilize the search function from the beginning. Link to comment
Level 5* DTLow 5,736 Posted July 6, 2016 Level 5* Share Posted July 6, 2016 1 minute ago, dyb_dzo said: My question was derived from "if note named thisTitle exists then" but it seems like i should utilize the search function from the beginning. Likewise, I could never get the "if exists" code to work I use the search function Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.