The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

can't get flattened context? Thread Tools Search this Thread Display Modes

i have been beating my head against this issue all morning and am out of gas so i thought i would actually ask someone for help.

i have been using Curt Clifton's "Complete and Await Reply Script" ( and it has been working great… until now.

Previously, my "Waiting" context was at the root level. I've been changing up and now context "Waiting" is a child of context "Communications". So I figured I would just need to insert some logic to get the flattened context and use it to create the new "Waiting for Reply re: … " Task.

The theory is sound but I have had no success getting the flattened context. I can get the script to run but it throws up an error saying "can't get flattened context where name is = "Waiting"' I tried place the logic in various depth of the process but always come up against the failure (at best). And of course i have been searching here for any clues but so far I am still at a loss.

Can someone help?

here is the necessary part of applescript as it stood, before i began.

property waitingForContext : "wait"
property waitingPrefix : "Reply on: "
property multipleItemsCompleted : "Multiple Items"

set itemTitle to missing value
tell application "OmniFocus"
	tell front document
		-- Gets target context
		set theContextID to id of item 1 of (complete waitingForContext as context)
		set theWaitingForContext to first context whose id is theContextID
		tell content of document window 1 -- (first document window whose index is 1)
			set theSelectedItems to value of every selected tree
			if ((count of theSelectedItems) < 1) then
				display alert "You must first select an item to complete." as warning
			end if
			repeat with anItem in theSelectedItems
				set itemTitle to name of anItem
				set theDupe to duplicate anItem to after anItem
				set completed of anItem to true
				-- Configure the duplicate item
				set oldName to name of theDupe
				set name of theDupe to waitingPrefix & oldName
				set context of theDupe to theWaitingForContext
				set repetition of theDupe to missing value
			end repeat
			if (count of theSelectedItems) > 1 then
				set itemTitle to multipleItemsCompleted
			end if
		end tell
	end tell
end tell
if itemTitle is not missing value then
	my notify("Completed and Awaiting Reply", itemTitle, scriptFinishNotification)
end if
thanks in advance,
That seems like the line you want to change.
set theWaitingForContext to first context whose id is theContextID
Is this what gives you errors?
set theWaitingForContext to first flattened context whose id is theContextID
yes, i think that's what i did - but then error 'can't get flattened context' appears.
Lizard - thanks a million - that did it!

Finally had a moment to sit down and test your suggested change - worked like a charm! I am unsure how I fouled it up before, probably missed the ID.

thanks again!

Can you tell me what your script was doing?

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

All times are GMT -8. The time now is 12:54 PM.

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