Passing an Obsidian link to OmniFocus URL in Keyboard Maestro

I have a macro in Keyboard Maestro that I use to manage upcoming meetings. When I run it, a prompt appears asking for the meeting topic and the date it will be held. That generates a new meeting template in Obsidian inside my meeting notes folder, then grabs the link to the Obsidian note and generates a task in OmniFocus using a shell script that URL encodes the variable values, and sets the due the day before the meeting date. I use this to help keep meetings I need to prep for throughout the week on my todo list.

The one piece that doesn’t work is saving the Obsidian note’s link to the notes section of the new OmniFocus todo. I can get around this in Things 3 with some tab key simulations to move into the notes field of that app, but the quick entry window on OmniFocus 3 doesn’t let you do that. So I tried adding the Obsidian link with the OmniFocus URL builder’s “note” tag, but passing that obviously isn’t URL-encoded the way the other variables I pass are and OmniFocus doesn’t save it.

Does anyone know how to get around this limitation of passing a URL to a local file inside of a shell script? Here’s the macro: Dropbox - Prepare for a Meeting with Obsidian and Omnifocus.kmmacros - Simplify your life

This is mostly an OmniFocus questions, so other locations you might look for an answer would be on the Keyboard Maestro forum or presumably OmniFocus has a forum as well.

Looking at your macro, you do not appear to actually use the link in your script:

urlencode() { … }

name=$(urlencode "$KMVAR_Name_of_meeting")
month=$(urlencode "$KMVAR_Month_of_meeting")
day=$(urlencode "$KMVAR_Day_of_meeting")
link=$(urlencode "$KMVAR_obsidianLink")

open "omnifocus:///add?name=Prepare%20meeting%20notes%20for%20$name&due=2023-$month-$day&tags=Meeting%20Prep"```

I imagine you could include the link in the note like this:

open "omnifocus:///add?name=Prepare%20meeting%20notes%20for%20$name&due=2023-$month-$day&tags=Meeting%20Prep - $link"```

I’m not sure if that is what you want or not.