View Single Post
Jason, here's a modification of part of Brian's script that should grab the items in your specified context if nothing is selected, instead of grabbing the flagged items. You'll need to replace the matching section of the original; I've put in a line or two of the original on each end.

Code:
property defaultTriggerInterval : -1440 -- interval between alarm and due date in minutes ("minus 1440" is 24 hours before due date)
property contextIfNoSelection : "Office" -- use tasks from this context if launched with nothing selected

set collectedTaskInfo to {}

--Step 1: collect highlighted items from OmniFocus, or flagged items if nothing is highlighted

tell application "OmniFocus"
	-- "window 1" is usually the frontmost window
	set theDoc to document window 1 of default document
	-- collect all the highlighted tasks in that window
	set TaskList to the value of the selected tree of the content of theDoc
	if (count of TaskList) is 0 then -- no items are selected, so let's get all the flagged ones
		tell default document
			set contextMatches to complete contextIfNoSelection as context maximum matches 1
			if ((count of contextMatches) > 0) then
				set contextId to id of first item of contextMatches
				set currentContext to context id contextId
				set TaskList to TaskList & (tasks of currentContext where blocked is false and flagged is true and completed is false)
			else
				display alert "Nothing selected and could not match context " & contextIfNoSelection
				return -- give up
			end if
		end tell
	end if
	
	repeat with theSelectedTask in TaskList
I'm skeptical about the ultimate value of this modification, as it's going to complain (and quit) if you have any actions in that context which don't have at least one date assigned. Putting dates on everything isn't a great practice, in my opinion, but if it works for you...