How do I write an automation to delete all labels on a page?
Asked by Paul Rathgeb:

I'm trying to figure out how to delete all labels on a page when a trigger occurs. I see a way to delete specific labels, but is there a way to delete all of them?

If it's NOT possible to create this automation, is there a way to restrict a space so that only specific Users can create labels?

Thank you!


Answers:
author: Jehan Bhathena
body: Hi [@Paul Rathgeb](/t5/user/viewprofilepage/user-id/5466412)

As per the documentation what you can try is use the "Remove Label" Action (<https://support.atlassian.com/cloud-automation/docs/actions-in-confluence-automation>),

with the page.labels smart value (<https://support.atlassian.com/cloud-automation/docs/smart-values-in-confluence-automation/#hardBreak>).

Let me know if this works.

comments: author: Paul Rathgeb
body: It appears that neither directly nor through a third-party app, that it is possible to control the use of labels. Such a pity. Labels could be very powerful, but given their implementation by Atlassian, the likelihood of clutter to the point of uselessness is very high. It would be great if we could better control and manage their use.


author: Jehan Bhathena
body: Hey [@Paul Rathgeb](/t5/user/viewprofilepage/user-id/5466412)

So you want to "Delete" the label altogether, and not just remove them from a certain page? Is that the use case you're targeting here?


author: Paul Rathgeb
body: Very close. The use case is: WHEN a trigger occurs, THEN remove all labels from the page.

I don't necessarily know what the labels are, but I know I want them all removed.

Another approach would be to simply limit who is allowed to add labels, but so far the resounding answer is, that's not possible.


author: Jehan Bhathena
body: [@Paul Rathgeb](/t5/user/viewprofilepage/user-id/5466412) with this as your use case "WHEN a trigger occurs, THEN remove all labels from the page", my first answer still applies.
> As per the documentation what you can try is use the "Remove Label" Action (<https://support.atlassian.com/cloud-automation/docs/actions-in-confluence-automation>),
>
> with the page.labels smart value (<https://support.atlassian.com/cloud-automation/docs/smart-values-in-confluence-automation/#hardBreak>).

For reference this is what the rule would look like:

![g0m1LjScfD.png](https://community.atlassian.com/t5/image/serverpage/image-id/325025iBFDDA659ED3BEB19/image-size/large?v=v2&px=999 "g0m1LjScfD.png")


author: Paul Rathgeb
body: Thanks. Unless I'm missing something, this rule requires one to know the label one wishes to remove. In my scenario, I won't know the label name, I just want to remove all labels from the page. Is there a wildcard character that removes all labels with this rule?


author: Jehan Bhathena
body: The Smart value page.labels.name does exactly that.

You can read up more on Smart values from the previously shared links ?


author: Paul Rathgeb
body: Wow! That works very well! Thank you!!!

I used a different trigger, as I am not sure how Manual Triggers work, but the rest is fantastic!!!


author: Stavros_Rougas_EasyApps
body: [@Paul Rathgeb](/t5/user/viewprofilepage/user-id/5466412) why do you need to remove all labels from certain pages.

We have a Confluence app, [Label Manager by Easy Apps](https://marketplace.atlassian.com/apps/1232224/label-manager-by-easy-apps?hosting=cloud&tab=overview) (it's also a feature of [Space Content Manager](https://marketplace.atlassian.com/apps/1226657/space-content-manager-find-and-replace-label-manager?hosting=cloud&tab=overview)), so I'm curious if this is a use case we should consider building.


Tags: automation

cloud

confluence-cloud

labels

space