AppleScript Error

I have an AppleScript that I run twice a day and have been doing for quite a while now, it is based on a script by Colter Reed.

Recently, possibly tied to one of the updates the scripts does not complete. I can capture the error, it is

/Users/Mac/Library/Mobile Documents/com~apple~ScriptEditor2/Documents/OmniFocusDailyMaintenance.scpt: execution error: OmniFocus got an error: AppleEvent timed out. (-1712)

This seems to be a generic error for an unspecified error so I was hoping for some help.

The script works, it works when run directly from within AppleScript and it works when run from LaunchControl and it works some of the time when scheduled.

Any thoughts or suggestions appreciated.

Thank you for your help.

Regards, Ian.

Could you share the script itself? Or at least a link to the one you based it on? It would be helpful for debugging to see where the problem is :)

@rosemaryjayne Hi the script is below. Thank you for your help, Regards, Ian.

on run
set todayDate to current date
set todayDate’s hours to 0
set todayDate’s minutes to 0
set todayDate’s seconds to 0
set tomorrowDate to todayDate + 1 * days

tell application "OmniFocus"
	tell default document
		set todayTasks to (flattened tasks where (defer date < tomorrowDate))
		repeat with t in todayTasks
			set t's flagged to true
		end repeat
	end tell
end tell


display notification "OF USER Script Completed @ " & (current date)

-- Lovingly crafted by David Sparks, The Omni Group, and Ben Waldie -- macsparky.com
-- Adapted by Ian Waddington

set theDate to current date
set theTask to "Script Ran - Check Actions - " & (theDate as string)

tell application "OmniFocus"
	tell front document
		set theContext to first flattened context where its name = "Any Device"
		set theProject to first flattened project where its name = "Personal Single"
		tell theProject to make new task with properties {name:theTask, context:theContext, flagged:true}
	end tell
end tell

end run