Clearing Tags and Adding New Tags Without a Prompt

I have an action that copies the Draft contents to the clipboard, adds a tag and archives the Draft.

Straightforward - nothing fancy…

What I am trying to do, to no avail is:

Remove the tag associated with the draft prior to invoking the Action.

So the new tag is the only tag on the draft.

Currently - the new tag is being set… but the old tag remains.

I’ve tried Remove Tag via TAD…
Namchuk and Agile Tortoises…
None have achieved the desired effect…

I do not want a prompt to do this… it’s the same “New Tag” being set each time.

Can anyone assist?

Thanks.

This script should remove any existing tags from the draft:

for (let tag of draft.tags) {
    draft.removeTag(tag);
}
draft.update();
1 Like

If you really do mean “prior”, then you would need to queue up the subsequent action after your action to remove all tags. If that is the aim, then some information about why you want to split it this way might be useful.

It would be interesting to see what you tried previously so we can see what the issue has been. I’m. guessing it might be to do with ordering and when any draft.update() calls were applied. But, without seeing what you tried, it isn’t possible to confirm for sure.

My objective - move a draft from one workspace to another after using the text in a post.
The action copies and selects all text, then moves the Draft through workspaces by changing tags.

Here is the action working properly but does not yet remove the original tag.

I incorporated the Action (see it here): TAD-Remove All Tags From Draft at the beginning of the Action and it throws this error:

Script Error: SyntaxError: JSON Parse error: Unexpected identifier “drafts”
Line number: 53, Column 35

All of that said, your script re-shared below - is the answer… My action works now:

for (let tag of draft.tags) {
    draft.removeTag(tag);
}
draft.update();

Thanks for your help.

This solved the problem - thank you.

You haven’t updated in a while then. There was a Drafts URL scheme change earlier this year and an update to the library to accommodate it.

1 Like

Will update- Thank you.