The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Getting task ID into variable - help :( Thread Tools Search this Thread Display Modes
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!

Last edited by StefMercury; 2011-07-28 at 01:05 PM..
 
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}
or
Code:
make new inbox task with properties {name:"test", note:"test 2", flagged:true}
set newTask to the result
In the second form you *must* get 'result' immediately after the command that generates that result, or it will be lost forever.

Last edited by teobaldo; 2011-07-28 at 11:40 PM..
 
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
 
Or even, (if id is the only property that you need to get from the new task object that is returned by the make 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
 
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 support ninjas 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.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Canvas Variable Parameters? chuise OmniGraffle General 4 2012-11-21 03:13 PM
variable for consecutive numbers? rauth OmniGraffle General 0 2009-02-19 01:28 PM
variable labels moving dghpts OmniGraffle General 0 2008-06-21 04:04 PM
Variable: Document philpalmieri OmniGraffle General 0 2008-05-02 05:50 PM


All times are GMT -8. The time now is 03:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.