Problems running Drafts actions from Shortcuts

I have 2 Drafts actions that I run every day: one is Dr. Drang’s script to move completed Taskpaper items to an Archive section at the bottom of the draft, and the other is a script to move all the Archive actions to a separate draft. I made a shortcut to run both of these Drafts actions automatically during the night, but the results are very inconsistent. Sometimes one of the Drafts actions will run, sometime neither. I have tried inserting pauses, tried splitting into two shortcuts and having them run 15 minutes apart; nothing seems to reliably work. Does anybody with success running Drafts actions from Shortcuts have any suggestions?

I don’t think that is a Drafts issue but more of a Shortcuts automation issue. At one point I couldn’t get any automation to run on a schedule between 00:00 and 06:00. In fact I still don’t schedule any automations for then, so I am unsure if that has changed in recent updates.

I have tied some of my automations to charging (on/off) and include a time of day check. A crude way of checking if I am going to bed for the day or getting up for the day; I then trigger some shortcut activities based on that.

I have a couple of suggestions based on those experiences that you therefore might care to try.

  1. Change the time of day that your automations are scheduled for.
  2. Change the trigger for your automations.

Hope one of those helps.

Thanks Stephen. I think you are onto something with the triggers, and I will look into that. But there is something going on with Drafts as well. Even if I run the shortcut manually, Shortcuts opens Drafts to the correct draft and claims to have run the action, but in fact the action does not fire. I will continue working on it and report back if I solve it.

If you share the details of the Shortcut and confirm the action runs when triggered within Drafts I think whatever is going on there can be figured out.

That would be amazing: I’d really like to get this to work, and I am out of ideas. I can confirm that the action works perfectly when I trigger it from within Drafts. The shortcut couldn’t be simpler: A single Drafts action: "Run Action on ". When I run the shortcut, it opens Drafts, the phone buzzes, and Drafts says that the action has been run. But nothing has happened.

Okay, so are you running whichever of the two actionsyou have mentioned; but first question has to be are you running it on the correct draft?

I’m assuming that each time there is work for the action to do that will modify the draft.

Is it a particular action that is working on the current draft or the editor?

Ok… even stranger: the action doesn’t alter the draft’s text on my phone the way it is supposed to when triggered with the shortcut. But: if I have the same draft open on my Mac, it does get updated appropriately on the Mac when I use the shortcut to trigger it. Then, later, the changes get synched back to the phone’s copy of the draft. If Drafts is not running on the Mac, then the action does nothing on the phone.

So to answer your questions:
I’m now quite sure I am running it on the right draft, because I can see that draft get updated on the Mac when I run the shortcut.

The action I want to get working is the “Archive@done” action from the Taskpaper action group:

Okay, I think there’s a timing / UI interface issue there in terms of when the draft gets loaded and when the action is being run. It is the issue that I figured you were most likely encountering, but it can be addressed by working directly with the draft content rather than with the editor content. It’s a simple modification to the script in the action to address this for the archiver action.

Here I’ve made the modifications to the Archive @done action (named Archiver @done) and it worked fine for me in my tests run from Shortcuts:

Essentially editor-based scripts are for when you are working directly with the draft. Draft-based scripts are more universal. There are times to use each and times to use them together, but in this instance, switching from editor-based to draft-based is practical and I think should give you better results.

I suspect the same scenario will apply to the second draft action you reference too. Just check through any script steps for any references to editor.

Give it a try and let us know how you get on.

Hooray, that did the trick! I was not aware of the editor vs. draft-based script distinction, but this made all the difference. Works for my other script as well. I will have to look into this some more and figure out when to use which. Thank you so much for taking the time to help me out, I really appreciate it!

By the way, for anybody stumbling on this thread who has a problem similar to mine, I will also add: I wanted to have one shortcut that would run two different drafts actions on the same draft. To get the results I wanted, I also had to add a short wait between the two actions, I suppose to give Drafts a chance to catch up.

Now everything works just the way I wanted!

I’ve not tried it with Shortcuts, and I’m just heading off to bed, but it would be worth looking to see if you could run a new action that queues the other two actions.