Log Completed Script

Hi guys,

The below script is one I have used for a long time triggered from LaunchBar so I can log adhoc tasks. It has stopped working and I have no idea what I need to change to get it working again.

The error I get on run is:
“OmniFocus got an error: The completion date can only be set on a completed task or project.”

This is the script:

Creates a Completed task in the folder, project, and context of your choosing.

Copyright � 2015-2017 Dan Byler (contact: dbyler@gmail.com)
Licensed under MIT License (http://www.opensource.org/licenses/mit-license.php)
(TL;DR: no warranty, do whatever you want with it.)


-	Initial version


1. set myFolderName to the name of the folder containing your the destination project
2. set myProjectName to the name of the destination project
3. set myContextName to the name of the destination context
4. Save this script in a place that can be indexed by LaunchBar or Alfred


property myFolderName : “Miscellaneous”
property myProjectName : “AdHoc”
property myContextName : “LogCompleted”

on log_item(myTask)
tell application “OmniFocus”
tell default document
– project
set myFolder to (get first folder whose name is myFolderName)
repeat with thisProject in (flattened projects in myFolder)
if name of thisProject is equal to myProjectName then
set myProject to thisProject
exit repeat
end if
end repeat

		-- context
		set myContext to (get first context whose name is myContextName)
		tell myProject
			make task with properties {name:myTask, context:myContext, completion date:(current date)}
		end tell
		display notification "\"" & myTask & "\"" & " logged to " & name of myProject
	end tell
end tell

end log_item

on handle_string(mystring)
my log_item(mystring)
end handle_string

on alfred_script(q)
end alfred_script

on run
tell application “OmniFocus”
set mystring to text returned of (display dialog “Log in” & myProjectName & “:” default answer “Completed task description”)
my log_item(mystring)
end tell
end run


Hey dmpohlmann, I posted an updated (but not well publicized!) version of the script here.

Basically, what happened is you used to be able to mark a task complete by setting the completion date to a specific time. Now you have to explicitly mark a task complete using the “mark complete” command: mark complete myTask

Not sure why The Omni Group made the change, but it’s a quick fix :) (Here’s the diff)


You are a legend! Thanks Dan!

It is working once all instances in script are ‘MyTaskName’.

Error still throwing even though it works:
Can’t make «class FCac» id “pQ7-_lCp4nq” of «class FCDo» of application “OmniFocus” into type Unicode text.

Any ideas?


Hi Dave, just seeing this. I haven’t seen that error before but I’d recommend you download Script Debugger and run the script from there. When the error presents itself…

  • Close the error dialog
  • Turn on the Event Log (View → Show Event Log), which will show the detailed log. Make sure Source view is selected.

That will turn it into a comprehensible error. :) Then feel free to ping me (my username @ gmail.com) and we’ll get it sorted.