Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Revert Changes to Multi Select Field using JIRA Automation

Ganesh Kumar Vary April 15, 2024

Hi,

We are using JIRA cloud. We have some fields that not supposed to be edited by users which are not part of a specific group. To achieve this, we used JIRA Automation that detects when ever the field is edited & edited by user not in specified group, update the field value with {{fieldChange.fromString}}.

 

The Step-By-Step detail is given below:

Trigger: When value changes for "Custom Field"

Condition: Initiator is not in group "User Group"

Action: Edit Fields "Custom Field" with {{fieldChange.fromString}}

 

The above automation is working fine for text fields. But when it comes to Multi Select fields, the Jira smart value {{fieldChange.fromString}} is returning a string which is not valid for  Multiselect custom field.

Eg: if the multi select custom field has values A, B, C selected, the smart value {{fieldChange.fromString}} is returning A,B,C as a string. If I try to load it to the custom field, the field is getting cleared as the format is not supported.

Can anyone help me solving this issue please.

Thanks & Regards,

Ganesh Kumar Vary

3 answers

0 votes
Alexa
Contributor
February 6, 2025

I was presented with the same problem as @Ganesh Kumar Vary

Following up on @Bill Sheboy's response, here's the solution I found -- in your automation rule, add the following components in this order:

  1. An IF or ELSE condition that checks for the authorized permissions, such as a user being in a group or not in a group.
  2. Create a variable.
    1. Name it whatever you'd like. I'm using 'previousValue' as my example.
    2. For the 'Smart value' field, use this to parse the multiselect values:
      1. {{fieldChange.from.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\s*,\\s*", ",").replaceAll("([^,]+)", "{\"id\":\"$1\"}")}}
  3. Edit issue fields.
    1. In the 'Additional fields' section, paste what's below:
      1. {
        "fields": {
        "customfield_XXXXX": [{{previousValue}}]
        }
        }
      2. Replace 'XXXXX' with your field ID.
      3. Replace the 'previousValue' text with whatever variable name you chose in the previous step (leave all the brackets in place).

This should successfully revert your custom multiselect field back to the previously selected value(s). Depending on the value options you have in your field, you may have to adjust 2.2.1 above to account for text variances. Here's are screenshots of the rule in case it's helpful (irrelevant components are blurred out):

2025-02-06_10-20-02.png2025-02-06_10-21-23.png

0 votes
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.
April 15, 2024

HI @Ganesh Kumar Vary 

Rather than using {{fieldChange.fromString}} you could use {{fieldChange.from}} to get the prior, selected id values, and then parse them to use advanced edit with JSON to set them back.

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--fieldChange--

https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Multi-select-custom-field

Kind regards,
Bill

0 votes
Matt Parks
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.
April 15, 2024

Do you have Scriptrunner? If so, then you could create a Behavior that would make the field read-only unless the user was in a particular group.

Otherwise, it appears that the rule would need to know what type of field it needs to set the value.

Suggest an answer

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

Atlassian Community Events