I keep a weekly list of links in Drafts. I’m trying to create a share-sheet Shortcut to run from iOS Safari that identifies the correct draft for the current week (by Draft title/first line) and appends a markdown link for the Safari page I’m viewing.
I have it working as long as a draft by the right name already exists (e.g., Links for 2019-11-26) – it identifies the next Tuesday, searches for a draft by the right name, and appends the link once it finds it.
However, I can’t figure out how to make it create the draft if it doesn’t already exist. I get an error. I have tried to use a Shortcuts If statement (e.g., If Draft has any value, or If Draft content has any value), but this seems to always create a new note in draft…
OK, that was interesting. Your shortcut worked perfectly. But when I tried to re-create it, I couldn’t get it to work. I finally figured out the problem, and it was very non-obvious:
First, I tried to use the Drafts action Add to Draft, which seems appropriate, because you can specify a draft, and there’s an Append option. It took a while to realize that you were using the Update Draft action.
Even then, I couldn’t figure out how you were using it — you updated a draft determined by your If statement – but when I tapped the field to identify which draft to append to, it gave me a search field; that search field identified existing drafts, but I wanted the result of the If statement. It took me forever to realize that, if I long-pressed on the same field, I could then select a magic variable (and thus the result of the If statement).
Either I’m particularly dense today, or Drafts could maybe use some better documentation for its Shortcuts actions…
That’s a Shortcuts thing. You’ll find several of places, particularly in third party actions, where when you want to select a magic variable, the default tap is insufficient and you need to access via a long press.