what is the fastest way to search tasks based on custom data in AppleScript
For some of my tasks I have a custom data field "tracid" set. In AppleScript I need to find the task where the tracid is set to a particular value.
Currently I am just iterating over the list of tasks until I find the one I want. Is there any faster way to do this? [CODE]-- Finds a Task -- _id : tracid of task on findTask(_id) tell application "OmniPlan" tell first document repeat with t in tasks set customData to get custom data of t if customData is not {} then if (tracid of customData = _id) then return t end if end if end repeat return false end tell end tell end findTask[/CODE] |
[CODE]
-- Finds a Task -- _id : tracid of task on findTask(_id) tell application "OmniPlan" tell first document set t to first task whose value of custom data entry "tracid" is _id if exists t then return t else return false end if end tell end tell end findTask [/CODE] |
Thanks for the help Lizard.
I tried your code and it causes an error when the task is not found instead of returning false. I think this is the ticket: [CODE] -- Finds a Task -- _id : tracid of task on findTask(_id) tell application "OmniPlan" tell first document try set t to first task whose value of custom data entry "tracid" is _id on error errmesg number errn if errn is -1719 then return false else error errmesg number errn end if end try return t end tell end tell end findTask [/CODE] |
All times are GMT -8. The time now is 01:36 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.