The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Asign Category and Project to Actions (http://forums.omnigroup.com/showthread.php?t=21551)

skillet 2011-07-07 07:18 AM

Asign Category and Project to Actions
 
Has anybody seen or written an apple script where you can modify the properties to automatically assign the category and project of selected actions. There are certain actions that are very common for me to do and it would be nice to just have them be assigned the right place to go at the end of the day in my in-box; instead of using the drop down from the inspector of multiple selected actions.

I know that there are delegated scripts that assign an action to a category but I am not having success modifying these.


Related:
The "AddFileToInbox" droplet would be awesome to have preassigned category and project to go into instead of just linking and going to the inbox for processing.
[url]http://www.cerquant.com/omnifocus_scripts[/url]

dbyler 2011-07-07 07:13 PM

FWIW, here's what I use to set context:


[CODE]set newContext to my getContext("home")
set context of thisItem to newContext

on getContext(contextName)
tell application "OmniFocus"
tell front document
set contextID to id of item 1 of (complete contextName as context)
return first context whose id is contextID
end tell
end tell
end getContext
[/CODE]

getContext returns the best match for a given string, so "home" would match "Home" before the "Home > Garden" context.

RobTrew 2011-07-07 07:53 PM

[QUOTE=dbyler;99335]
getContext returns the best match for a given string, so "home" would match "Home" before the "Home > Garden" context.[/QUOTE]

And if there is no match, you can always extend getContext to create one:

[CODE]on getContext(contextName)
tell application "OmniFocus"
tell front document
try
first flattened context whose name contains contextName
on error
(make new context with properties {name:contextName})
end try
end tell
end tell
end getContext[/CODE]

skillet 2011-07-08 01:55 PM

Neither of those are working for me, I have tried many ways to modify them to get them to work but no success.


[CODE]
property contextName : "Home"


tell application "OmniFocus"
tell front document
set contextID to id of item 1 of (complete contextName as context)
return first context whose id is contextID
end tell
end tell
end
[/CODE]

[CODE]on getContext("Home")
tell application "OmniFocus"
tell front document
try
first flattened context whose name contains "Home"
on error
(make new context with properties {name:"Home"})
end try
end tell
end tell
end getContext[/CODE]

Sorry I am dumb as a nail. If you could spare the time, could you show an example of what you use on multiple selected actions that have no context and projects and you want to put them in context "Work : Online" (online being a context of work) and project "Research" in a Marketing folder.

I am not sure if you have to define the folders if there are multiple projects named "Research". Seems confusing to define since they can even be in the same folder with the same name.

Anyway just the context part would be helpful to me if the project part is too complicated.

RobTrew 2011-07-08 09:47 PM

For oft-repeated batch assignments, you could specify the project name (and the name of its containing folder), together with the context name, at the top of a script of this general shape.

[CODE]property pProjFolder : "Marketing"
property pProjName : "Research"
property pContextName : "Online"


tell application "OmniFocus"
tell front document
set oProject to first flattened project where (its name = pProjName) and (name of its folder = pProjFolder)
set oContext to first flattened context where name = pContextName

tell content of front document window
set lstTasks to (value of selected trees where class of its value is inbox task or class of its value is task)
repeat with oTask in lstTasks
set context of oTask to oContext
move oTask to end of tasks of oProject
end repeat
end tell
end tell
end tell[/CODE]

skillet 2011-07-09 04:12 PM

Angels sing and the clouds part! I will be using this everyday, thank you Rob (& Dan)!!


All times are GMT -8. The time now is 06:06 PM.

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