The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Set project status to completed not working in script? (http://forums.omnigroup.com/showthread.php?t=7857)

dmwatlse 2008-04-26 02:07 PM

Set project status to completed not working in script?
 
Hi folks--
I've been trying to make a script that will allow me to mark projects completed from context view, since I get tired of switching over to do this. Unfortunately, something mysterious is happening: my changing of the project's completed status doesn't "take." I can successfully change the project's name or note, but not its completed status or completion date. Any thoughts? I stole the first bit of this code from the "reveal" script available [URL="http://forums.omnigroup.com/showpost.php?p=24025&postcount=1"]here[/URL].

[CODE]property toolName : "Mark Project Complete"

tell front document of application "OmniFocus"
(* get the window the user is using *)
set |w| to first document window whose index is 1
tell |w|
set theItems to selected trees of content

if ((count of theItems) is 0) then
display alert ¬
"Select an action to " & toolName message "You have not selected an action"
return
end if

if ((count of theItems) is greater than 1) then
display alert ¬
"Select just one action to " & toolName message "You have selected more than one item, please select just one"
return
end if

set selectedItem to value of item 1 of theItems

--set selectedItem to item 1 of theItems

if ((class of selectedItem) is not task) then
display alert ¬
"Select an action to " & toolName message "You have selected something that isn't an action"
return
end if

end tell
set P to containing project of selectedItem
if (P is missing value) then
display alert ¬
"Select an action to " & toolName message "You can't mark the inbox complete!"
return
else
(* a real project, not the inbox *)
tell application "OmniFocus"
set note of P to "Kilroy was here" --this works
set completed of P to true
set displaytext to completed of P as rich text
set completion date of P to current date
set displaytext to displaytext & " " & completion date of P as rich text
display dialog displaytext --shows "false" and "no value"
end tell
end if
end tell[/CODE]

RobTrew 2008-04-26 04:13 PM

You could try setting the [B]status[/B] property of the project to [B]done[/B].

dmwatlse 2008-04-26 11:10 PM

[QUOTE=RobTrew;36064]You could try setting the [B]status[/B] property of the project to [B]done[/B].[/QUOTE]
Ah hah! Yes, when I did that first, and then changed the completed and completion date properties, it worked like a charm.

Thanks!


All times are GMT -8. The time now is 06:10 PM.

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