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

Looking for an add action example Thread Tools Search this Thread Display Modes

I'm looking for an Applescript example (or a pointer) for what needs
to be done to add an action.

For bonus points I like to know the form/format of any string directives
that set project/context.

In another posting I saw

' .... "> Project" and/or "@ Context" to the action ' ....

Can be used in some way to affect the add.

Any example would be great ...

I really want to call the (apple)script from the command line as in:

bash% add2omnifocus "actionString > Project @ Context"

Any hints most welcome... (and thanks to Omni for this program and
the support from the community)

... looking in the iGTD2OmniFocus script (awesome!)

I see some code that's close to what I want, but I'm not sure I fully understand it yet... I'm talking about:

set my text item delimiters to "~|~"
tell application "OmniFocus" to tell first document
repeat with oTaskRecord in InboxTasks
if length of oTaskRecord > 0 then
set oFields to text items of oTaskRecord
set oNewTask to (make new inbox task with properties {name:(item 1 of oFields), note:(item 2 of oFields)})
my SetTaskDetails(oNewTask, oFields)
end if
end repeat
end tell


This is close... since it lands tasks into the Inbox, just as I desire...

Any other ideas....??????
That is pretty much the syntax for an inbox task

make new inbox task with properties {record}

You can check properties are available in the dictionary.

What was it that you wanted to do beyond that?

If you want to use the fancy "task @ Context > Project..." syntax, you can use this syntax:

tell application "OmniFocus" to tell document 1
	parse tasks with transport text "The Text"
end tell
The parse tasks will also do the Mail rule's trick of finding new tasks on every line prefixed with "--".

If you want the Bash script, you can do the following:

1. Create an AppleScript with the following code:

on run argv
  tell application "OmniFocus" to tell default document
    parse tasks with transport text argv
  end tell
end run
Then from the command line, you're looking for a command like:

$ osascript /path/to/thescript.scpt "Task @ Action > Project"
Writing that into a Bash script ought to be pretty straightforward.

Note that if you want to be able to send the command without enclosing quotes, you'll need to pass the arguments to the script as a single string, or have the script concatenate them.

It's also possible to enclose the whole thing in the shell script itself, using osascript -e "first line of script" -e "Second line of script" syntax, but that can get pretty painful, especially once you consider escaping characters for bash as well as for AppleScript. I much prefer the simple "pass this argument to the script" method. (Plus it can be as simple as an aliased command, rather than a bash script as well as the AppleScript)

Last edited by iNik; 2007-12-06 at 11:52 AM..
Many thanks - This works just as I desired!!



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unwanted Loc. reminders now for an action due in Jan [A: add start date to action] jman995x OmniFocus for iPhone 4 2011-12-01 01:39 PM
Why is this action purple? [ANSWER: Use single action list if no next action wanted] actuary gtd OmniFocus 1 for Mac 6 2010-01-22 01:38 PM
Restoring deleted proj./action on Mac [A: Open OmniFocus backup on Mac, copy action.] MichaelG OmniFocus for iPhone 4 2009-08-31 09:52 PM
Omitting Action Group results from Next Action filter AmberV OmniFocus 1 for Mac 12 2009-07-19 07:57 AM
Due date of child action as reference of parent action jochen OmniFocus 1 for Mac 1 2009-02-22 05:35 AM

All times are GMT -8. The time now is 10:19 AM.

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