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 > OmniPlan > OmniPlan Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Find and get/set completed of Task with AppleScript Thread Tools Search this Thread Display Modes
Hi folks,

I'm new to AppleScript and I want to get/set the completed value of specified tasks.
I tried many ways but it does not work.
I'm only able to get the overall Percentage of the Project.
Any idea? Here is my try.

Thank you verry much.
Olbea

Code:
tell application "OmniPlan"
	activate
	set xString to "Vorgang 1"
	
	tell front document
		set xoutput to title of it
		set foundTask to (every task whose name is xString)
		set xoutput to completed of it  --gets project percentage
                -- I tried this: (1)
                -- set xoutput to completed of first task of foundTask
                -- But it does not work 
	end tell
	
	tell front window
		set selected tasks to foundTask
	end tell
end tell

xoutput
Error (1): error "„task 1 of {task id 1 of scenario 1 of project of document \"Ohne Titel.oplx\" of application \"OmniPlan\"}“ kann nicht gelesen werden." number -1728 from «class Optk» 1 of {«class Optk» id 1 of «class OPso» 1 of «class OPpj» of document "Ohne Titel.oplx"}
 
Got a solution :)
Hope it helps anybody.


Code:
tell application "OmniPlan"
	activate
	set xString to "Neuer Task  2" -- uniqe name of my task
	
	tell front document
		-- set xoutput to title of it
		-- set foundTask to (every task whose name is xString) -- many results possible
		set foundTask to (first task whose name is xString) -- only one result
		set xoutput to completed of foundTask
		-- set completed of foundTask to 1.0 --set to 100%
	end tell
	
	--set xoutput to completed of document 1
	
	tell front window
		set selected tasks to foundTask
	end tell
end tell

xoutput
 
Better way to work with results I think. ;)

Code:
tell application "OmniPlan"
	activate
	set xString to "Vorgang 1" -- uniqe name of my task
	
	tell front document
		set foundTask to (every task whose name is xString) -- many results possible
		set lengthoutput to length of foundTask --for future :)
		set xoutput to completed of item 1 of foundTask
		-- set completed of foundTask to 1.0 --set to 100%
	end tell
	
	tell front window
		set selected tasks to item 1 of foundTask
	end tell
end tell


xoutput
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



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


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