Grab "text" portion from incoming Drafts URL scheme?

I’m trying to create an action that will grab text sent from Editorial (or really anywhere I guess). In other words, I am sending this from Editorial:

drafts5://x-callback-url/runAction?text=TEXT&action=MYACTION

I would like to then create a javascript for MYACTION that could reference the TEXT sent to drafts from that URL. Is there an object or variable for this already?

(My real end result is I’m trying to figure out a way to do a roundtrip from Drafts to Editorial. Right now my idea is to send the full content of the draft to editorial with the Draft UUID as the first line. Then, when Editorial sends the text back, I’d like the script to grab the first line of the text, which will be the UUID, use that to load that Draft, then replace the text of the draft with the rest of the text sent from Editorial).

The value in the text parameter will be the content of the draft…so in a script draft.content would equal TEXT in your example.

A draft is always in context when an action is performed. Using /runAction a temporary draft is still created and used as the draft object in the context.

1 Like

Thanks Greg! Here’s the set of actions if anyone’s interested:

https://actions.getdrafts.com/a/1Q9

1 Like

Is there a way to delete the file in Editorial when returning to avoid local file clutter?

I’m not certain, but it doesn’t look like it. I think there may be two ways to deal with this:

  1. Send the text from drafts to create a file in Editorial in the Dropbox sync folder, then use api scripting to delete from Dropbox.
  2. Send the text from drafts to the same file in Editorial every time (rewriting over the same file) rather than creating a new file.

Neither of these fit with my workflow, so I’ve not investigated further, but I think either could be a solution.