An Applescript that creates an Omnifocus project from a Tinderbox Note and reciprocally links them

I almost always use Tinderbox to brainstorm topics and projects in order to figure out what I need to do, and then I track the actual project/tasks in Omnifocus. I wanted to automate the process of creating an Omnifocus project from a note, and copy/pasting reciprocal links between Omnifocus and Tinderbox.

This script:

  • Creates a new project in Omnifocus named after the currently selected Tinderbox note of the frontmost open Tinderbox document.
  • The “Notes” field of the new Omnifocus project contains the “$NoteURL” from the Tinderbox note.
  • The Omnifocus project’s “task URL” is copied to the Tinderbox note’s “$URL”
  • The Tinderbox Note’s “$KeyAttributes” is changed to “$URL;” (Note: I don’t bother with $KeyAttributes for this kind of brainstorming. If you don’t want a note’s $KeyAttributes replaced, you will have to modify this or delete the relevant line).
  • The script colors the Tinderbox note (I just love that “poppy” color!) and gives it a badge so I can identify which notes I have added to Omnifocus.

Hopefully posting this helps anyone who has been looking for similar functionality in their workflow.

Applescript:

5 Likes

Thanks for the pre-formatted text tip! [Edited now!]

Regarding task creation:
AFAICT, the Omnifocus URL scheme doesn’t distinguish between tasks and projects. If I decide the project I created in OF via the script is a subtask of another project, moving it in OF doesn’t break the link. I do use this script to create new items in OF that I manually drag into projects as subtasks.

Some extensions or versions of the script I am planning on trying out (in order of personal usefulness):

  • A version that looks through the contents of the Tinderbox note for child notes flagged somehow (e.g. a boolean attribute “$include_in_project”), and creates them as subtasks when invoking the script.
  • Instead of creating a project in the top-level directory, a version of the script that looks to see if the Tinderbox note is the child of a Note already linked to an Omnifocus project, and creates the item as a sub-task of that project or task in OF.
  • A version that works with multiple selected notes in Tinderbox. Right now it only works with a single selection.

If I implement any, I will update this thread.

Also, copying over due dates, start dates, etc. would be possible but I usually do all that kind of nitty-gritty in Omnifocus, so probably won’t ever bother.

What a nice contribution @yggy. Thank you!

Is it possible to scale in the sense of having all notes subordinated to the one note that – through your script – becomes an OmniFocus Project become subordinated tasks in the OmniFocus project as well?

1 Like

Thanks for the kind words!

I think the first bullet in my list of planned additions above describes what you suggest, but with an option to include/exclude. It is possible and planned, but I want to wait and use the script as it is for a bit first.

For my purposes, it may be an advantage to require a discrete action for every added task in Omnifocus. Very easily, my Omnifocus becomes less of a task manager and more of a hybrid task-manager / research collector / word processor / wish-list, and it becomes unpleasant to use.

FWIW, I have used the Forum discussions above almost every day to transfer Task notes in Tinderbox to the Inbox of Omnifocus. I’ve made some revisions that I’m posting here in case they might be useful to others.

This AppleScript works on a selection of Tinderbox task notes, typically collected using an Agent. The script creates a new task in the Inbox of Omnifocus for each Tinderbox note selected, and copies some information for back linking as well. As a final step, the AppleScript turns the Tinderbox “Checked” attribute to “true” so that it is no longer an active task in Tinderbox .

tell application "Tinderbox 10"
	activate
	try
		-- Get the front document
		tell front document
			-- Get the selected notes
			set selectedNotes to selections
			
			-- Loop through each selected note
			repeat with aNote in selectedNotes
				-- Get the name of the current note
				set noteName to value of attribute "Name" of aNote
				--- Get the name of the current note
				set theTaskName to value of attribute "Name" of aNote
				set theTaskText to value of attribute named "NoteURL" of aNote
				set theProjectID to value of attribute named "OmniFocusProjectID" of aNote
				set noteURL to value of attribute named "NoteURL" of aNote
				-- create inbox task in Omnifocus
				tell front document of application "OmniFocus" to make new inbox task with properties {name:theTaskName, note:theTaskText}
				set value of attribute "Checked" of aNote to true
				set value of attribute "Badge" of aNote to "link"
				set value of attribute "Color" of aNote to "poppy"
				-- add processed comment to Text attribute
				set noteText to value of attribute "Text" of aNote
				set value of attribute "Text" of aNote to (noteText & "Processed on " & (current date) as string)
			end repeat
		end tell
	on error errorMsg
		display dialog "Error: " & errorMsg
	end try

3 Likes

Can’t wait to try this I had many failed attempts on trying to get something like this working.

I’m a bit confused by the code:

  • variable noteName is created and then never used elsewhere in the script
  • variable projectID is set to the value of user attribute OmniFocusProjectID – but at that point in the script the script would not yet know the project ID, right?
  • variable 'noteURL` is created then never used elsewhere in the script
  • wouldn’t it be useful to have OF return the OF link to the newly created task and then have the script store that link in a user attribute?
  • There is an 'end tell` missing at the end, otherwise the script will not compile

With script generation help from ChatGPT, here’s a suggested revision, which works for me (limited testing on non-production data). Make sure to create a user attribute OFtaskURL as a URL-type attribute, in advance of using the script.

tell application "Tinderbox 10"
	activate
	try
		-- Get the front document
		tell front document
			-- Get the selected notes
			set selectedNotes to selections
			
			-- Loop through each selected note
			repeat with aNote in selectedNotes
				-- Get the name and other attributes of the current note
				set theTaskName to value of attribute "Name" of aNote
				set theTaskText to value of attribute named "NoteURL" of aNote
				
				-- Call function to create OmniFocus task and get the URL
				set taskURL to my createOmniFocusTask(theTaskName, theTaskText)
				
				-- Update the "OFtaskURL" attribute in Tinderbox with the OmniFocus task URL
				set value of attribute "OFtaskURL" of aNote to taskURL
				
				-- Update other note attributes in Tinderbox
				set value of attribute "Checked" of aNote to true
				set value of attribute "Badge" of aNote to "link"
				set value of attribute "Color" of aNote to "poppy"
				
				-- Add the processed comment and task URL to the Text attribute
				set noteText to value of attribute "Text" of aNote
				set value of attribute "Text" of aNote to ((noteText & "Processed on " & (current date) as string) & ", OmniFocus Task: " & taskURL)
			end repeat
		end tell
	on error errorMsg
		display dialog "Error: " & errorMsg
	end try
end tell

-- Function to create a task in OmniFocus and return the task URL
on createOmniFocusTask(taskName, taskText)
	tell application "OmniFocus"
		tell front document
			-- Create a new inbox task
			set newTask to make new inbox task with properties {name:taskName, note:taskText}
			-- Get the URL of the new task
			set taskURL to "omnifocus:///task/" & (id of newTask)
			return taskURL
		end tell
	end tell
end createOmniFocusTask

I would probably want better error handling and debugging built in, but that’s all for now.

1 Like

Thank you, @PaulWalters, for showing me a cleaner, simpler way to write this AppleScript! I admit I uploaded a work-in-progress … still learning here. Grateful!

1 Like

It’s an excellent concept @ptc97504, I just cleaned up around the edges. This sort of automation is very useful, and could easily be embedded in a Shortcut, too. Thank you for contributing your approach!

works great. thank you!

one question @PaulWalters: how to set the default version of Tinderbox being used by OmniFocus when clicking the newly created task’s backlinks.

  • Right clicking on the backlink in OF shows Tinderbox 9.x being set as default …
  • although I have the most current version of Tinderbox 10.x installed …
  • and in Finder all .tbx-Files are set to open within Tinderbox 10.x by default.

Thanks

@andreas to be honest, I’m not sure. On my Mac the OF task note is set to a URL of the form

tinderbox://GG3020?view=outline+select=1725658346

which is created automatically inside Tinderbox as the value of the $NoteURL system attribute, and passed verbatim to OF. So, I would check Tinderbox to see what it’s doing with that attribute.

Also, select a .tbx file in Finder, open Finder’s “Get Info” and see what version of Tinderbox is assigned as the “Open with” app for that file type.

Finally, I noticed when I installed Tinderbox 10 that Tinderbox 9 was still there, for some reason, and causing some issues with Tinderbox 10. So, I zipped up v9 and the issues stopped.

macOS keeps a database that associates applications with documents. Two different versions of any application can confuse this database; archiving the older version will fix this.