Page 1 of 1

Send a document (or link to a document) to 2do app

PostPosted: Wed Jul 13, 2016 10:37 pm
by djb21au
I use the 2do app on OSX for reminders, and have been trying to create a script in Hazel to create a reminder. I'm a novice at scripting, but as I understand it 2do does not have Applescript support but does have a URL scheme ( http://2doapp.com/kb/article/url-schemes.html)

After a few searches of similar scenarios I came up with the following shell script:

Code: Select all
do shell script "open 'twodo://x-callback-url/add?task=Claim reimbursement" & "&Note=" & theFile & "'"


I don't really understand how it works but it does, creating a new 2do item in the Inbox, with the file name and path as a note. However it has limited usefulness as there is no link to that document, which is what I'd really like to add.

Could anyone provide any guidance on how I might make this more useful by adding a link to the file instead of just its name and path?

Re: Send a document (or link to a document) to 2do app

PostPosted: Fri Jul 15, 2016 11:50 am
by Mr_Noodle
I think you may want to contact the support team for the 2do app. It looks like the details are things that they are responsible for, which is how to make a link and pass that in.

Re: Send a document (or link to a document) to 2do app

PostPosted: Fri Jul 15, 2016 7:30 pm
by djb21au
Thanks. I actually worked out a solution combining the instructions in this post here (http://www.noodlesoft.com/forums/viewtopic.php?f=3&t=1770) and a script I found in an Alfred workflow.

In case others are interested, the applescript I'm using in Hazel is below. This creates a new 2do item with a link to the file as an action. Before running the code, Hazel temporarily renames the file with the pattern (FILENAME|FILE PATHNAME):

Code: Select all
tell application "Finder"
   set myHazelTokenDelimiters to "|"
   set theListOfCustomTokens to name of theFile
   set AppleScript's text item delimiters to {myHazelTokenDelimiters}
   -- Now, the tokens are available in theListOfCustomTokens as items 1,2,3 etc...
   
   set taskName to text item 1 of theListOfCustomTokens
   set listName to text item 2 of theListOfCustomTokens
   set urlScheme to "twodo://x-callback-url/add?task=" & taskName & "&action=url:file://" & listName
   tell application "System Events"
      open location urlScheme
   end tell
end tell