The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniPlan Extras (http://forums.omnigroup.com/forumdisplay.php?f=45)
-   -   Simple Applescript, Create Task, Assign resource, Assign dependency (http://forums.omnigroup.com/showthread.php?t=24714)

dexterama 2012-06-27 08:27 AM

Simple Applescript, Create Task, Assign resource, Assign dependency
 
Hello,

Newbie question that I have been wrestling with...I am sure somebody can clear this one up. I am trying to create a simple series of tasks (that have child tasks), that get assigned to a resource (person) that already exists in the resources area. I would (eventually) also like to add a dependency between child tasks as well. Right now...what I have looks like this (without the assign dependency part)...

set CTime to (current date)
tell application "OmniPlan"
tell first document
set newTask to make new task with properties {name:"sillyTask"}
tell newTask
set camTask to make new task with properties {name:"Camera", starting date:CTime, duration:36000}
set bagTask to make new task with properties {name:"Bag", starting date:CTime, duration:36000}
assign camTask to resource whose name is "Jamie"
assign bagTask to resource whose name is "Sam"
end tell
end tell
end tell


It creates the 'sillyTask' with child tasks 'Camera' and 'Bag', but I get an error saying...

Can’t get resource whose name = "Jamie".

...even though the resource/s clearly exist. I am sure it is simple scripting problem, but I have tried all manner of syntax...but just can't seem to get the resource name. Heeeeellllppp??

dexterama

PS. I would then like to make a dependency so that 'Bag' happens at the end of 'Camera'

dexterama 2012-06-29 10:02 AM

Duh...
 
...so yeah...it was a newbie question. Figured it out eventually. I guess I just needed to declare the resource better. For those that care....

set CTime to (current date)
tell application "OmniPlan"
tell first document
set newTask to make new task with properties {name:"sillyTask"}
tell newTask
set camTask to make new task with properties {name:"Camera", starting date:CTime, duration:36000}
set bagTask to make new task with properties {name:"Bag", starting date:CTime, duration:36000}

--Declare your resource (person)
set personJamie to resources whose name is "Jamie"
set personSam to resource whose name is "Sam"

-- Assign the task to the resource
assign camTask to personJamie
assign bagTask to personSam

-- Set up your dependency
depend bagTask upon camTask

end tell
end tell
end tell

jim lee 2012-11-18 12:25 PM

Actually I care, this looks like exactly what I'm trying to do. Thanks for the starting point!

-jim lee


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

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