How to clear the only one value from Label field while moving to other status

Lakshmi S April 22, 2021

Hi Team,

 We have request from user to clear the Label field value, not all values, we need to clear one specific value.

 Project ticket moves from Design IP to DOR CHECK by a member of Analytics Implementation Solution Strategists, the "TRACK" label field value should be removed automatically, and should not clear the whole field values, we have multiple label field values.

We are jira server 8.13.3, and we have JMWE, JSU, Script runner addons.

Could you please suggest on this ?

Thanks!

2 answers

1 accepted

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 22, 2021

Hi @Lakshmi S ,

actually, JMWE can also do this. You can add a Set Field Value post-function with the following configuration:

  • Field: Labels
  • Value type: Groovy Expression
  • Value:
issue.get("labels")?.findAll{it.label != "TRACK"}
Lakshmi S April 23, 2021

Hi @David Fischer , Thank you so much for your quick response.  Its working.

labels.PNG

Dawn Fama May 26, 2021

Will this option clear any labels of linked issues?  We would like to clear a label when workflow transitions from Fixed to Ready for Test but only if label value = blah and like the issue above if the label has more than 1 value, we don't want it to clear other values. 

The other dilemma is that we don't want to clear label values for any sub tasks linked to that specific issue.

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 22, 2021

Of the three apps you have, only Scriptrunner can do this.

You can write a script that:

  • Reads the current label field (which gets you a "collection" of all the labels in use)
  • Iterates over the collection and either
    • Copies everything you want to keep to a new collection
    • Removes the label(s) you do not want from the collection
  • Writes the new/updated collection back to the label field

https://library.adaptavist.com/entity/update-the-labels-for-an-issue-in-jira should have most of the code for writing, and suggest how you go about reading too.

Suggest an answer

Log in or Sign up to answer