How do I remove inactive users from the field using Jira Automation?

Mari Pervushina
Contributor
November 14, 2024

Hello!

Please help me with the Jira Automation. I need to change a multi-user field so that role removes inactive users from it. Otherwise, it is a pain in the Data Center when there are inactive users in the field, then another rule cannot change the values of this field until inactive users are removed.

I have some test rule. And i going to be change it so removing only inactive users. How i can use IF? It will be something like that:

IF({{#issue.customfield_10053.name.active}} == false, remove ... {{/}})

As a result, the multi-user field will contain only active users.

2024-11-14_19-06-35.png2024-11-14_19-07-43.png

Additonal fields text:

{ "update": { "customfield_10053" : [ {{#issue.customfield_10053.name}}{"remove": {"name":"{{.}}"}}{{^last}},{{/}}{{/}} ] } }

2 answers

1 accepted

4 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 14, 2024

Hi @Mari Pervushina 

Are you trying to remove the inactive users from:

  1. the selected values in the field, or
  2. from the list of possible values to select?

 

The first one could be done by filtering on active equaling true, and replacing the selections using a JSON expression.  That could be this:

  • action: create a variable
    • name: varActiveUsers
    • smart value:
{{#issue.customfield_10053}}{{#if(active)}}{{name}},{{/}}{{/}}

Test with a condition that the variable is not empty, and then set the values with JSON, or clear the field if not of the users were active.

{{#if(exists(varActiveUsers))}}
{
"fields" : {
"customfield_10053": [
{{#varActiveUsers.substringBeforeLast(",").split(",")}}
{ "name": "{{.}}" } {{^last}},{{/}}
{{/}}
]
}
}
{{/}}

As you started in your rule, you could invert this to use not(active) for the removals with an "update", and that will require testing if there are no values to remove.

 

The second one (i.e., removing from the list of possible values) would require calling the REST API to change the available options / users in the field configuration.

 

Kind regards,
Bill

1 vote
Mari Pervushina
Contributor
November 15, 2024

Hi @Bill Sheboy 

It is works greate! Thank you very very much!

Suggest an answer

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

Atlassian Community Events