View Single Post
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