How to add multiple tags with 1 line of script


I know I’ve posted a lot recently, but hope someone will be able to help on this as well.

I assume the answer is pretty simple, but I just can’t find the information I am looking for

There are a some actions that start by defining a tags, and applying that tag to a new draft in the end.

My question is how do you do this for multiple tags?
For example I have an action that starts with something like this
const logTag = "list";
And later it will
How do you add multiple tags for “list”, “act-on”, “work” for example?

For now, my work around is to just add them in sequence

const logTag1 = "list";
const logTag2 = "act-on";
const logTag3 = "work";

Which is fine for now, but this means I need to tweak multiple areas of the script(at least the end), and it can mess up queries in the middle of the script.
I was hoping for a solution like
const logTag = "list", "act-on", "work";
(this did not work)
Where you only need to change 1 of the lines.

There is probably a very simple solution, and this may be a very stupid question, but any help would be appreciated.

Thank you

You could have a script like this…

const TAGS = ["list", "act-on", "work"]; => draft.addTag(strTag));

Then you only have to change the first line to manage the array of tags.

Or, you could really have a one-liner…

["list", "act-on", "work"].map(strTag => draft.addTag(strTag)), draft.update();

Hope that helps.

Thank you!

To clarify though, this example would mean I need to change the scrip for to add the code to the draft right?

Looking at agiletortoise’s “Add to list” action as an example (it is actually originally the one I wanted to be able to add multiple tags with)

Towards the start

const listTag = “lists”;

Then after multiple things happen,


Towards the end.

Is there a way to just change the former, keeping the latter intact, and still add multiple tags?
Or maybe that just isn’t how the latter script works?

Use the first script…

The second script was how you would do it in one line, which is what your post title asked for :wink:

1 Like

Thank you.
Very much appreciated!

1 Like