Applescript for setting context

This script sets a specific project to the currently selected tasks.

Code:

-- unlocked2412
-- This script sets a specific project to the currently selected tasks.

property the_project_name : "" -- CHANGE THIS PROPERTY VALUE TO REFLECT YOU DESIRED PROJECT

tell application "OmniFocus"
	set o_doc to front document
	tell o_doc
		set the_project_value to first flattened project whose (name = the_project_name)
	end tell
	set o_win to front document window of front document
	tell o_win
		tell content
			set lst_tasks to value of selected trees
			if lst_tasks ≠ {} then
				repeat with i in lst_tasks
					set the_task to contents of i
					move the_task to end of tasks of the_project_value
				end repeat
			else
				display dialog "Select one task, please"
			end if
		end tell
	end tell
end tell
2 Likes