Need help with combine two scripts

All right folks! Here is the deal. I’m finding use cases both for Open random draft by tag By @galtenberg and thisby @_ry

I want to take it to the next level and combine these two scripts above. Then it will be a perfect local alternative to ReadWise. One could simply dump all quotes in a single draft and based on line, extract one of them, pass as variable and get alert with one of quotes.

I tried to modify different parts of these scripts, but couldn’t get my head around how to make it work.

Snippet from the first script:

app.openURL(`drafts5://x-callback-url/open?uuid=${randomDraft.uuid}`)
}

Snippet from the second action:
var fullFragDraft = Draft.find(‘UUId-of-the-draft’)

Could someone point to the right direction how to pass UUId variable from first action to second action?

If you’d like to pass a draft based on UUID, then you probably want to use the Template engine. Here are the docs.

There’s another thread here which talks about passing data between actions that you might want to read about as well.

I think this combines the two.

Just modify the function in the random chooser to return the UUID (no return was defined for the function previously) and not open the draft, then use that function call as the input to the find rather than the hard coded string. There does not seem to be any reason not to put them into a single step in a single action.

1 Like

I change my mind. How do I modify open random note by tag action to get content of a random draft in an alert instead of opening a draft itself?

Swap the line that opens the draft

app.openURL(`drafts5://x-callback-url/open?uuid=${randomDraft.uuid}`)
}

for a line that alerts it’s content.

alert(random Draft.content);