At some point my script needs to know whether the task it is dealing with is contained directly by its project, or in a task group.
I figured it out but it doesn't look very convincing. Is there a better way? Here's my code:[CODE]if id of container of thisTask ≠ id of containing project of thisTask then -- it's in a task group -- do the appropiate thing else --do the other thing end if[/CODE] |
I might use some variant of
[I]parent task is root task of containing project[/I] [CODE]tell application id "com.omnigroup.omnifocus" tell content of front document window of front document set lstTasks to value of selected trees set oTask to first item of lstTasks tell oTask set blnIsInGroup to (parent task is not root task of containing project) end tell end tell end tell[/CODE] |
or, of course:
[CODE]set blnInGroup to (container is not root task of containing project)[/CODE] but I notice that the execution speed of your approach: [CODE]set blnInGroup to (id of container ≠ id of containing project)[/CODE] is fractionally faster ... [COLOR="White"]--[/COLOR] |
Oh, great.
I picked the 'best' solution... :grin: Not that it is [U]that[/U] great. Would be easier with a 'task group' class. |
To expand task groups during import
I needed this in order to work around the absence of a 'task group' class.
When [URL="http://forums.omnigroup.com/showthread.php?t=19397"]importing[/URL], projects are created in expanded state, but task groups are not. They can't be, because they only become task groups after a child is created (obvious when you have experienced the mess which results when ignoring this). The script now checks in what type of container a list of tasks will be created. If it's a task, the script expands the new task group after the first child is created. Now it can also paste the childrens' notes, which is the purpose of the exercise. (I use UI scripting because my notes have a lot of formatting, which I do not want to loose). Earlier I was trying to do this in the routine which creates the tasks, but after some reshuffling the solution became somewhat simpler. Here is the routine that processes the task list:[CODE]-- Recursively create tasks in current project -- Flag condition where parent is a task -- parameters: list of tasks in Mori -- OmniFocus item in which to create tasks from entryList -- (a project on first entry) -- returns: nothing on processEntries(entryList, refOmniNode) tell front document of application "Mori" set currentNode to "" tell front document of application "OmniFocus" to set boolIsTask to (class of refOmniNode is task) set taskCount to count entryList repeat with i from 1 to taskCount set refMoriTask to item i of entryList -- tell subroutine to only expand parent first time set boolExpandParent to (i = 1 and boolIsTask) set currentNode to my createTask(refMoriTask, refOmniNode, boolExpandParent) if entries of refMoriTask is not {} then -- has children set children to my listEntriesSorted(refMoriTask) my processEntries(children, currentNode) -- go deeper end if end repeat end tell end processEntries[/CODE] |
All times are GMT -8. The time now is 07:35 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.