How to create an automation rule that compares the field Reporter with Request participants?

Nahuel Logghe
Contributor
April 12, 2024

Hello!

I want to create a rule that checks if the Reporter is set as a Request Participant and if that is the case to remove it from the field.

Since request participants have multiple values I have no clue how to achieve this.

Ideas?

2 answers

1 vote
Anna Hryhoruk _Appfire_
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

Hello @Nahuel Logghe ,

Are you considering any marketplace apps? If yes, I can show you how to make one using the Power Scripts app and the SIL scripting language. 

The SIL script like this will do what you need: checks if the reporter of an issue is listed among its participants, and if so, it removes the reporter from the list of participants associated with the issue.

string[] AllParticipants = %key%.#{Request participants};
string IssueReporter = %key%.#{reporter};

if (contains(AllParticipants, IssueReporter)) {
%key%.#{Request participants} = arrayDeleteElement(AllParticipants, IssueReporter);
}

But it may need some extra rows depending on how/when you want to trigger it.  In case you want this script to be triggered by the change of field value reporter or request participants, this should  be configured as SIL Listener for "Issue Updated event" with the following script: 

JFieldChange[] changes = lastIssueChanges(key);

for (JFieldChange c in changes) {
if (c.field == "customfield_10029" || c.field == "reporter") { // 10029 is Request participants custom field ID


string[] AllParticipants = %key%.#{Request participants};
string IssueReporter = %key%.#{reporter};

if (contains(AllParticipants, IssueReporter)) {
%key%.#{Request participants} = arrayDeleteElement(AllParticipants, IssueReporter);
}
}
}

In summary, this script will monitor changes to specific fields in an issue (reporter and requested participants), and if one of those fields is modified and the reporter is listed among the participants, it removes the reporter from the list of participants associated with the issue. 

Adding some helpful documentation pages: Simple Issue LanguageSIL Listener, Array functions, SIL manager .

Hope it helps! 
Anna

Nahuel Logghe
Contributor
April 15, 2024

Hi Anna,

Thank you very much. The option you are showing definitely seems to be what we need. Unfortunately, I don't think it's worth paying for the plugin's fee at this time since we will only use it for this specific case, which is not very common. Perhaps in the future, if other situations arise where we need to create scripts for our automation rules, we might consider purchasing this plugin. In any case, I am very grateful for the comprehensive solution you have provided.

Like Anna Hryhoruk _Appfire_ likes this
1 vote
Tansu Akdeniz
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 12, 2024

Hi @Nahuel Logghe 

You can try the solution in this thread to remove user from the list.

Jira Automation remove a user from Approvers

Nahuel Logghe
Contributor
April 15, 2024

Hi Tansu,

Thank you very much for your response. I have reviewed that post and the other links contained within it as well. I have no experience with scripting. I understand that the script removes a fixed element from a list, but I'm wondering if it's possible to adapt that script to meet my specific needs. I need to compare two different values from two fields and conditionally remove one. The example provided doesn't seem to match my case, and I lack the expertise to modify it

Specifically, I need to compare the 'Reporter' field with the 'Request Participants' field, and if the reporter is listed among the Request Participants, then they need to be removed from Request Participants. Perhaps my approach is not correct, and there might be another way to do this?

Suggest an answer

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

Atlassian Community Events