The Omni Group Forums

The Omni Group Forums (
-   OmniPlan Extras (
-   -   Applescript return resources in group? (

dexterama 2012-07-04 10:29 AM

Applescript return resources in group?
Hello again,

I have a list of human resources (with unique names) that have been grouped together under a unique group name. Is there a simple way to get applescript to return the list of names under the specified group name, or count the number of resources under the group?



dexterama 2012-07-04 01:09 PM

Count of tasks assigned
In addition to the above problem, I am trying to get a count of number of tasks assigned to a specific resource. I have a schedule of 9 tasks and a resource called "Frank" who has 5 of the 9 tasks assigned to him. I am trying to run something like the following...

tell application "OmniPlan"
set resourceName to "Frank"
tell front document
set numTasksAssigned to (count of tasks with resource whose name is resourceName)
if ((count of numTasksAssigned) < 1) then
display alert "There are no tasks assigned to resource " & resourceName
end if
end tell
end tell

But I get a 'Can't get 9 whose name = "Frank"' error. Ultimately, it should just return the number 5. I am sure my syntax is wrong. Any help would be greatly appreciated.



whpalmer4 2012-07-04 01:41 PM

Here's a rough idea of how you might do something like this:

tell application "OmniPlan"
tell front document
set my_group to first resource where (resource type is resource group) and (name is "3 Stooges")
my print_group(my_group)
set my_resource to first resource where (resource type is person) and (name is "Bill")
set my_count to number of assignments of my_resource
display alert "Bill has " & my_count & " task(s) assigned"
end tell
end tell

using terms from application "OmniPlan"
on print_group(this_resource)
if (resource type of this_resource is resource group) then
set group_count to number of (child resources of this_resource)
display alert "found a group named " & name of this_resource & " with " & group_count & " items"
repeat with a_resource in child resources of this_resource
end repeat
end if
if (resource type of this_resource is person) then
display alert "found a person named " & name of this_resource
end if
if (resource type of this_resource is equipment) then
display alert "found equipment named " & name of this_resource
end if
if (resource type of this_resource is material) then
display alert "found material named " & name of this_resource
end if

end print_group
end using terms from

dexterama 2012-07-04 02:03 PM

This is exactly what I needed....thank you so much whpalmer4! Works like a treat.

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

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