Script to create isolated copy of repeated task stopped working

Hello and greetings,

I have been using this script for ages:

Its Functionality: when you select a repeated task and start the script it did the following:

  • Marks the repeated task complete (so that the new instance according to the next repeat is created)
  • Marks the Task uncompleted and deletes its repetion scheme and adds an (I) in front of the taskname

With this script I had an isolated copy of a repeating task without breaking the repeating scheme

Somewhen during the database changes to Omni 3 this script stopped working - instead of making changes on the completed task it changes the created next occurance of the task - so i have a next occurance with deleted repetion and a completed task with repetion :(

It seems that before the Ominfocus changes aTask was always the selected item whereas now aTask is the new instance when you complete a task

any hint how to change it hat it continues to work

tell application “OmniFocus”
set will autosave of front document to false

tell content of front document window of front document
set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder)

  repeat with aTask in validSelectedItemsList
  	if repetition of aTask is not missing value then
  		#    			set completed of aTask to true
  		mark complete aTask
  		mark incomplete aTask
  		#				set completed of aTask to false
  		set repetition of aTask to missing value
  		set name of aTask to "(I) " & name of aTask
  	end if
  end repeat

end tell

set will autosave of front document to true
end tell

Looks like this is still an issue, and I modified it by adding an additional loop that seems to fix the issue on my end. 👍🏼

tell application "OmniFocus"
	set will autosave of front document to false
	
	tell content of front document window of front document
		set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder)
		
		repeat with aTask in validSelectedItemsList
			if repetition of aTask is not missing value then
				# set completed of aTask to true
				mark complete aTask
			end if
		end repeat
	end tell
	
	# additional loop to re-select the original task
	tell content of front document window of front document
		set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder)
		
		repeat with aTask in validSelectedItemsList
			if repetition of aTask is not missing value then
				# set completed of aTask to false
				mark incomplete aTask
				# remove the repetition of the old task
				set repetition of aTask to missing value
				# add a prefix to distinguish between the two
				set name of aTask to "(I) " & name of aTask
			end if
		end repeat
	end tell
	
	set will autosave of front document to true
end tell
2 Likes