How to return issues.labels which starts with a certain string in rule automation

priyank_agrawal November 21, 2020

I have a rule to remove the labels fields whenever an issue is edited. I want to remove the label field only if it starts with a certain string, ex- abc.

So if I have two labels, abc-123 and pqr-234, the rule should remove the abc-123 from labels list. I have a tried a lot of different smart values in rule advance json but it ends in json error. 

How to achieve it?

1 answer

1 accepted

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 24, 2020

Hi @priyank_agrawal  -- Welcome to the Atlassian Community!

There is no smart value function to remove one item from a list field yet.  The work-around I found was to use string, list, and create variable handling:

  1. Add a condition to look for the value you want to remove.  If found...
  2. Capture the Labels list as a string, using Join() or an iterator to make it a delimited list, and put it into a Created Variable
  3. Use the string Remove() function to remove your target label, placing the result in another Created Variable
  4. Use the Split() function to separate back into a list to replace the Labels value

If you instead want to update Labels with advanced editing JSON, change the above step (2) to format in the JSON syntax, and change step (4) to leave the item as a string.

Try this, and if you need more details, here is a step-by-step for how to do this with Component replacement. The same method should work for Labels.

Here is the documentation on advanced field editing with JSON, the string functions, and the list functions I used to do this:

https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/

https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/

https://support.atlassian.com/jira-software-cloud/docs/smart-values-lists/

 

Best regards,

Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events