I need a little help. I have this great applescript that i created from searching online, and it works great. Now I wanted to be able to add tags in the evernote note and I can’t figure out what I am doing wrong. Can someone point me in the right direction?
Here is my script:
set theDate to do shell script "date +'%d %b %y'"
set dialog1 to (display dialog "Date of change?" default answer theDate with title "Changes Log Input")
set dialog2 to (display dialog "What is the change?" default answer "" with title "Changes Log Input")
set dialog3 to (display dialog "Who created the change?" default answer "" with title "Changes Log Input")
set dialog4 to (display dialog "Change report by?" default answer "" with title "Changes Log Input")
set dialog5 to (display dialog "Please enter tags with comma seperation" default answer "" with title "Changes Log")
set button1_clicked to button returned of dialog1
set button2_clicked to button returned of dialog2
set button3_clicked to button returned of dialog3
set button4_clicked to button returned of dialog4
set button5_clicked to button returned of dialog5
set note_date to text returned of dialog1
set note_change to text returned of dialog2
set note_created to text returned of dialog3
set note_by to text returned of dialog4
set note_tag to text returned of dialog5
set dlg to {"Date: " & note_date & return, "Change: " & note_change & return, "Source: " & note_created & return, "Report by: " & note_by} as string
tell application "Evernote"
tell notebook "Default Notebook"
set new_note to create note with text dlg as string
set title of new_note to note_date & space & "- " & note_change
set tags of new_note to note_tag --this is where I am having a problem
end tell
end tell
To judge from this Web page, the Evernote creation syntax should look something like this:
tell application "Evernote"
set new_note to (create note title (note_date & space & "- " & note_change) with text dlg notebook "Default Notebook")
set Tag1 to (make tag with properties {name:note_tag})
assign Tag1 to new_note
end tell
This (if it works!) will of course assign the entire, comma-delimited input string to the one tag. If you wanted a separate tag for each comma-delimited item, I’d guess your script should be something like below, but I don’t have Evernote either.
set theDate to do shell script "date +'%d %b %y'"
set dialog1 to (display dialog "Date of change?" default answer theDate with title "Changes Log Input")
set dialog2 to (display dialog "What is the change?" default answer "" with title "Changes Log Input")
set dialog3 to (display dialog "Who created the change?" default answer "" with title "Changes Log Input")
set dialog4 to (display dialog "Change report by?" default answer "" with title "Changes Log Input")
set dialog5 to (display dialog "Please enter tags with comma seperation" default answer "" with title "Changes Log")
set button1_clicked to button returned of dialog1
set button2_clicked to button returned of dialog2
set button3_clicked to button returned of dialog3
set button4_clicked to button returned of dialog4
set button5_clicked to button returned of dialog5
set note_date to text returned of dialog1
set note_change to text returned of dialog2
set note_created to text returned of dialog3
set note_by to text returned of dialog4
set note_tag to text returned of dialog5
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set note_tags to text items of note_tag
set AppleScript's text item delimiters to astid
set dlg to {"Date: " & note_date & return, "Change: " & note_change & return, "Source: " & note_created & return, "Report by: " & note_by} as string
tell application "Evernote"
set new_note to (create note title (note_date & space & "- " & note_change) with text dlg notebook "Default Notebook")
repeat with this_tag in note_tags
set new_tag to (make tag with properties {name:this_tag})
assign new_tag to new_note
end repeat
end tell
I have been fixing up my script for the past two hours, searching on the web and finding other scripts and I have now managed to input ONE tag to the note! Yeah!!! Now I need to figure out how to input multiple tags. Nigel, I tried your script and Evernote comes up with the following error:
error “Evernote got an error: AppleEvent handler failed.” number -10000
and it highlights this part of the script:
make tag with properties {name:this_tag}
Maybe from my slightly revised script, we can figure this out.
Here it is:
set theTitle to "Changes Log Input"
set theDate to do shell script "date +'%m/%d/%Y'"
set d1 to (display dialog "Date of change?" default answer theDate with title theTitle)
set d2 to (display dialog "What is the change?" default answer "" with title theTitle)
set d3 to (display dialog "Who created the change?" default answer "" with title theTitle)
set d4 to (display dialog "Change report by?" default answer "" with title theTitle)
set d5 to (display dialog "Put a finder tag (one word)" default answer "" with title theTitle)
set b1 to button returned of d1
set b2 to button returned of d2
set b3 to button returned of d3
set b4 to button returned of d4
set b5 to button returned of d5
set note_date to text returned of d1
set note_change to text returned of d2
set note_source to text returned of d3
set note_by to text returned of d4
set note_tag to text returned of d5
set note_comb to {"Date: " & note_date & return, "Change: " & note_change & return, "Source: " & note_source & return, "Report by: " & note_by} as string
tell application "Finder"
tell application "Evernote"
tell notebook "Default Notebook"
set new_note to create note with text note_comb tags note_tag
set title of new_note to note_date & space & "- " & note_change
end tell
end tell
end tell
Nigel, Thanks for your help, your repeat part worked with a little amendment.
Now I got it working to add more than one tag!!! Almost there!
The only thing now is that when I run the below script it still has an error, but it at least adds the tags.
The error is as follows:
error “Evernote got an error: Can’t make "test" into type tag, list of tag.” number -1700 from “test”
The below is the script, please point me in the right direction to now just handle this error message (or null it somehow!).
set theTitle to "Changes Log Input"
set theDate to do shell script "date +'%m/%d/%Y'"
set d1 to (display dialog "Date of change?" default answer theDate with title theTitle)
set d2 to (display dialog "What is the change?" default answer "" with title theTitle)
set d3 to (display dialog "Who created the change?" default answer "" with title theTitle)
set d4 to (display dialog "Change report by?" default answer "" with title theTitle)
set d5 to (display dialog "Put a finder tag (one word)" default answer "" with title theTitle)
set b1 to button returned of d1
set b2 to button returned of d2
set b3 to button returned of d3
set b4 to button returned of d4
set b5 to button returned of d5
set note_date to text returned of d1
set note_change to text returned of d2
set note_source to text returned of d3
set note_by to text returned of d4
set note_tag to text returned of d5
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set note_tags to text items of note_tag
set AppleScript's text item delimiters to astid
set note_comb to {"Date: " & note_date & return, "Change: " & note_change & return, "Source: " & note_source & return, "Report by: " & note_by} as string
tell application "Finder"
tell application "Evernote"
tell notebook "Default Notebook"
set new_note to create note with text note_comb tags note_tags
set title of new_note to note_date & space & "- " & note_change
repeat with this_tag in note_tags
set new_tag to this_tag
assign new_tag to new_note
end repeat
end tell
end tell
end tell
That’s because the script’s trying to assign text to the note instead of an Evernote ‘tag’ object. But I don’t know why you’re unable to create the tag in the first place. The syntax is exactly what’s given on the Evernote documentation page to which I linked above.
Ok, so with help also from the Evernote Developers, it is now finally resolved and I am posting it here:
set theTitle to "Changes Log Input"
set eIcon to path to resource "ev.icns" in bundle (path to me)
set theDate to do shell script "date +'%m/%d/%Y'"
set d1 to (display dialog "Date of change?" default answer theDate with title theTitle with icon eIcon)
set d2 to (display dialog "What is the change?" default answer "" with title theTitle with icon eIcon)
set d3 to (display dialog "Who created the change?" default answer "" with title theTitle with icon eIcon)
set d4 to (display dialog "Change report by?" default answer "" with title theTitle with icon eIcon)
set d5 to (display dialog "Put finder tags with comma" default answer "" with title theTitle with icon eIcon)
set b1 to button returned of d1
set b2 to button returned of d2
set b3 to button returned of d3
set b4 to button returned of d4
set b5 to button returned of d5
set note_date to text returned of d1
set note_change to text returned of d2
set note_source to text returned of d3
set note_by to text returned of d4
set note_tag to text returned of d5
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set note_tags to text items of note_tag
set AppleScript's text item delimiters to astid
set note_comb to {"Date: " & note_date & return, "Change: " & note_change & return, "Source: " & note_source & return, "Report by: " & note_by} as string
set new_note_date to (date note_date)
tell application "Finder"
tell application "Evernote"
tell notebook "Default Notebook"
set new_note to create note with text note_comb tags note_tags
set creation date of new_note to new_note_date
set title of new_note to note_change
end tell
end tell
end tell