Getting task ID into variable - help :(
Hi, I am totally new to scripting - thus far all I want to be able to do is create a new task from Filemaker Pro into Omnifocus - I have a script that does this.
The snippet which makes the new tasks is below - obviously I substitute variables in place of the hard coded strings. BUT, how do I get the ID of this newly created task so I can store it in a variable? I have tried set myTaskID to id of task as a command directly after the make new inbox task but this fails --- I have tried what seems like 100 other variations. tell application "OmniFocus" tell the first document make new inbox task with properties {name:"test", note:"test 2", flagged:true} end tell end tell Could anyone help an idiot?! Thank you P.S. I am also an idiot because I posted this to the wrong forum! Not sure how to delete this and start again! |
Getting task ID into variable - help :(
Hi, I am totally new to scripting - thus far all I want to be able to do is create a new task from Filemaker Pro into Omnifocus - I have a script that does this.
The snippet which makes the new tasks is below - obviously I substitute variables in place of the hard coded strings. BUT, how do I get the ID of this newly created task so I can store it in a variable? I have tried set myTaskID to id of task as a command directly after the make new inbox task but this fails --- I have tried what seems like 100 other variations. tell application "OmniFocus" tell the first document make new inbox task with properties {name:"test", note:"test 2", flagged:true} end tell end tell Could anyone help an idiot?! Thank you |
Catch the result of the 'make' command like so:[CODE]set newTask to make new inbox task with properties {name:"test", note:"test 2", flagged:true}[/CODE]
or[CODE]make new inbox task with properties {name:"test", note:"test 2", flagged:true} set newTask to the result[/CODE] In the second form you *must* get 'result' immediately after the command that generates that result, or it will be lost forever. |
Either of these should work:
[CODE]tell application "OmniFocus" tell front document set oTask to (make new inbox task with properties {name:"test", note:"test 2", flagged:true}) set strID to id of oTask end tell end tell -- OR tell application "OmniFocus" tell front document tell (make new inbox task with properties {name:"test", note:"test 2", flagged:true}) set strID to id end tell end tell end tell[/CODE] |
Or even, (if [I]id[/I] is the only property that you need to get from the new task object that is returned by the [I]make[/I] command):
[CODE]tell application "OmniFocus" tell front document set strID to id of (make new inbox task with properties {name:"test", note:"test 2", flagged:true}) end tell end tell[/CODE] |
Thank you for that....so easy when you know how :)
|
Thank you!!!!
This has only driven me mad for 3 days. Thank you for your time in answering that one...greatly appreciated. |
Glad this got sorted out, but please don't post items in multiple threads to try and up the chances of getting a response - it makes the forums less useful for other guests.
If you need a guaranteed response, it's better to post to the forums and then email the [EMAIL="omnifocus@omnigroup.com"]support ninjas[/EMAIL] about the thread. Thanks! (Merging threads.) |
Sorry Brian - I did put in the other post I had posted to the wrong forum and didn't know how to delete! Regards.
|
All times are GMT -8. The time now is 02:17 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.