Run action URL scheme does not include draft body in Mail action

Hello all,

Anytime I have travel expenses at work, I append the information to a set draft using an action. Then each month or so, I send the list via email using another action. Typically I will open the draft for review, then I look for the action to send the email and I’m set.

In order to not look every time for this last action, I included a URL scheme to run it directly from the draft. The action launches fine, but the email does not include the body of the draft as intended, that part is empty. Anyone would know how to resolve this?

The text template from the mail action looks like this:

Bonjour,
<br><br>
Voici mon kilométrage facturable en date du [[date|%Y-%m-%d]] : <br>
<br>
%%[[body]]%%
<br>
Merci,

And the URL to run the action: drafts://x-callback-url/runAction?action=Mail%20km

I don’t include a text argument in the url, although according to the DraftsGuide it would be required.

Thank you in advance for your help!

Actions are run with a specific draft in context, that is used as the draft who’s properties will be filled in when template tags are expanded. When you are in the app, and run an action from the action list, etc., that draft is the one currently loaded in the editor.

When you run an action from outside the app, via the /runAction URL, the action is run with a new, blank draft in context - so [[body]] will return and empty string.

If you have a specific draft that already exists in the app, and you want to run an action with it in context via URL, use the /open URL, with the action parameter, something like:

drafts://open?uuid=UUID-OF-DRAFT&action=NAME-OF-ACTION

Note that this might be easier to setup with Shortcuts these days, where Drafts also has a “Run Action on Draft” action.

1 Like