Get a note and copy to clipboard does not work

My action gets a specific note using the UUID, and copies to the clipboard. I get the note fine, but the copy is blank. I think I need a slight delay after I get the note, because if I get the note, and then copyseparately, it works fine, but if I put the 2 steps together in an action it does not work.

Any help?

Hey Rolfess! It’d be helpful to see the action you’re working with, assuming it doesn’t contain anything you don’t want to share. That’d make it easier for someone to offer feedback/advice.

Actually, thinking about it, this could be done with two lines of JavaScript, if I’m understanding your workflow correctly:

let d = Draft.find("UUID-HERE")

No wait/pause required.

Actions are run on a specific draft. Usually this is the draft currently loaded in the editor, if you running the action by tapping on it in the action list.

Action steps like the clipboard step will operate on that draft.

I’m not sure how you are getting “a specific note by UUID”, but if that is in a script, or URL, etc., that does not affect the draft that is in context for the action.

So your clipboard step is probably working, but not getting the result you expect because it’s putting the draft that was in the editor when you ran the action into the clipboard (which is maybe blank).

@jsamlarose’s script above should accomplish what you want in a single script step.

1 Like

I don’t know how to copy the action, but it’s about as simple as your JavaScript:

Define Template Tag Tag:[[TargetUUID]]
URL drafts://open?uuid=[[targetUUIOD]]
Clipboard replace, [[draft]]

The first two lines work. And the last line also works. But when I put them together into one action, the clipboard ends up empty.

I can try the JavaScript, but these are standard Drafts commands, so they should also work.


Thanks, I replied before I saw your note.

I understand now how it works, and I can adjust. Just out of curiousity why does it work that way instead of copying what is in the draft when the copy command is executed? It’s not intuitive, at least to me.

And thanks to both of you for your help.

Thank you! That worked perfectly as you said it would!

1 Like

I do not know what you mean by “in the draft”? I think you mean in the editor? There are many cases where that would not make sense.

Actions can be run on drafts that are not ever loaded in the editor (like if they are run via URL scheme, or launched from the Home Screen widget or Shortcuts), and you would have very indeterminate results for some things - like if the action is set to archive/tag the draft after success, should it be doing that to the one you started the action with, or the one you loaded in the editor during the course of the action?

Note there are ways to trigger actions for drafts other than the current one, like app.queueAction (docs), if you want to lookup a draft and run and action with it as the draft in context.

1 Like

Ahh, I see your point, and that makes sense. I am definitely not very knowledgeable, although I have put together some actions that work fine for me. This is all helpful, thank you for jumping in.