The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   can't get flattened context? (http://forums.omnigroup.com/showthread.php?t=31289)

WilliamThirteen 2014-02-06 02:45 AM

can't get flattened context?
 
Hi,

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" ([url]http://www.curtclifton.net/projects/[/url]) 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.

[CODE]
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
return
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

[/CODE]

thanks in advance,
William

Lizard 2014-02-12 01:01 PM

That seems like the line you want to change.
[quote]set theWaitingForContext to first context whose id is theContextID[/quote]

Is this what gives you errors?
[quote]set theWaitingForContext to first flattened context whose id is theContextID[/quote]

WilliamThirteen 2014-02-17 01:04 AM

yes, i think that's what i did - but then error 'can't get flattened context' appears.

WilliamThirteen 2014-02-25 03:43 AM

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!
cheers,
William

cdw5510 2014-02-26 09:55 AM

William,

Can you tell me what your script was doing?


All times are GMT -8. The time now is 11:05 AM.

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