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

 
Simple Task Creation Script Thread Tools Search this Thread Display Modes
Hey folks,

I'm sorry this is such a stupid question. I just need a script that creates a task with the same name as a variable in AppleScript. I've found a bunch of other scripts that create events (like the MailAction script inside of OF's bundle) but they're doing a lot of other stuff so I'm struggling to pair it down to something as simple as "create task with the name variableName".

FWIW, this is for Siri integration without using e-mail. It's complicated to setup at first, and requires an always on machine, but does the trick. Basically it imports reminders into OF so you can say "remind me to…" instead of "e-mail Task Contact 'task name'". I'll definitely share the complete solution when it works. I have everything working I just need the last little bit to get it into OmniFocus.

If I could also get a script that will do the above and let me specify a context from a variable I think I might be able to hack "Remind me to get milk, context Groceries" but I'm not 100% sure because it requires some more text processing.

Thanks! OF support pointed me here, they don't seem to have a simple create script example.
 
The main elements might look something like this:

Code:
on run
	set {strProj, strContext, strTask} to {"Proj1", "Context3", "TaskTitle"}
	
	MakeTask(strProj, strContext, strTask)
end run

on MakeTask(strProj, strContext, strTask)
	tell application id "OFOC"
		tell default document
			
			-- WHERE WILL IT GO (A PROJECT OR THE INBOX) ?
			if strProj ≠ "" then
				set lstProj to flattened projects where name = strProj
				if lstProj ≠ {} then
					set oProj to first item of lstProj
				else
					set oProj to make new project with properties {name:strProj}
				end if
				
				tell oProj to set oTask to (make new task with properties {name:strTask})
			else
				set oTask to (make new inbox task with properties {name:strTask})
			end if
			
			-- WHICH CONTEXT IF ANY ?
			if strContext ≠ "" then
				set lstContext to flattened contexts where name = strContext
				if lstContext ≠ {} then
					set oContext to first item of lstContext
				else
					set oContext to make new context with properties {name:strContext}
				end if
				set context of oTask to oContext
			end if
		end tell
		
		return oTask
	end tell
end MakeTask

Last edited by RobTrew; 2011-10-19 at 12:00 PM.. Reason: default document probably safer than front document
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Applescript, Create Task, Assign resource, Assign dependency dexterama OmniPlan Extras 2 2012-11-18 01:25 PM
Reducing task overload and bad multitasking by means of a simple feature Marek Kowalczyk OmniFocus 1 for Mac 5 2012-10-07 07:37 PM
Script: listing tasks by their creation date RobTrew OmniFocus Extras 0 2011-07-26 02:29 AM
Simple question about task length change santra OmniPlan General 1 2008-03-13 03:46 PM
Bug in new no-Context task creation? rajrsingh OmniFocus 1 for Mac 1 2007-10-05 12:01 PM


All times are GMT -8. The time now is 09:35 AM.


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