Call draft tags individually in Action

I’m attempting to build an action that requires breaking out individual tags with the following syntax:

~[[tag|1]] ~[[tag|2]] ~[[tag|3]]

As this doesn’t appear to be supported in https://docs.getdrafts.com/docs/actions/templates.html, I wonder if:

B - Might this be supported in the future?
A - Could someone offer a method for accomplishing the same result in another way?

You can reference an array of the tags in scripting and output them to any format you care to choose.

Where are you ‘breaking them out’ to? The clipboard, the existing draft, a new draft, an e-mail, a URL,…?

The goal is for them to wind up as the last line of the acted-on draft, which then gets drafted as an email. I was afraid that I’d wind up having to learn more JS to get this done :stuck_out_tongue:

Try:

let tags = draft.tags.map(t => `~${t}`).join(" ");
draft.setTemplateTag("formattedtags", tags);
// use [[formattedtags]] in subsequent action steps
1 Like

Flawless! Thank you Mr. Pierce :heart:

1 Like

Would you mind explaining the first line a little? The map function is fine. It’s what the squiggly bracket text means that will confuse people.