Need help on ScriptRunner groovy script for Jira

83 Views Asked by At

We use Jira Service Management Cloud version. And we have license for ScripRunner. I recently trying my best to explore and use ScriptRunner Listener as an alternative to Jira Automation Rules.

The business requirement is to automatically assign values to 2 custom fields (Functional area and Resolver group) based on the value of cascading field Issue category/sub-category.

In Jira, I used the IF-ELSE condition to populate Functional area and Resolver group when the Issue category/sub-category is updated/changed. However, Jira have a limit of 65 conditions within a single rule.

I tried Script Runner Listener to on another (simple) requirement, which is working perfectly. I've search the web far and wide and I could not find a similar solution to address our business requirement. I hope someone here can help me.

I pasted below a snippet the conditions I wrote in Jira Automation for reference (the actual automation rule has 65 conditions). In Adaptavist webpage, I saw a sample script that uses the "switch > case" logic.

project = "Sigma SDM " AND issuetype in (Incident, "Service Request with Approvals", Problem) AND
"Issue category" in cascadeOption ("Application (Non-SAP)", "MedAdvisor") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Fred") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "HealthEngine") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "KIA") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "LAMLab") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Last Yard") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "LOTS") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "MINFOS") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Navision") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Plexus") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "RPM") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Snap'n'Share") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Z") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Blueprint") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Corum") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "JDA") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Qualtrics") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "SpaceMan") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "Wageloch") OR
"Issue category" in cascadeOption ("Application (Non-SAP)", "eCommerce AMCAL/DDS")

  • Functional area: Commercial / Resolver group: IT Commercial

project = "Sigma SDM " AND issuetype in (Incident, "Service Request with Approvals", Problem) AND "Issue category" in cascadeOption ("Application (Non-SAP)", "Salesforce")

  • Functional area: Commercial / Resolver group: IT Salesforce

project = "Sigma SDM " AND issuetype in (Incident, "Service Request with Approvals", Problem) AND "Issue category" in cascadeOption ("Application (SAP)", "Concur")

  • Functional area: Corporate / Resolver group: SAP Concur

project = "Sigma SDM " AND issuetype in (Incident, "Service Request with Approvals", Problem) AND
"Issue category" in cascadeOption ("Application (SAP)", "OpenText") OR "Issue category" in cascadeOption ("Application (SAP)", "FICO") OR "Issue category" in cascadeOption ("Application (SAP)", "Finance Supply") OR "Issue category" in cascadeOption ("Application (SAP)", "Finance Tech")

  • Functional area: Corporate / Resolver group: SAP Finance Management

... ... ...

Thanks for your help.

I have not tried anything yet as I'm not familiar with groovy script of ScriptRunner.

The expectation is:

  • When the Jira user updates the cascading fields for Issue category and sub-category, the system will auto populate the 2 custom fields: Functional area and Resolver group.

I was hoping to use the ScriptRunner Listener module for this.

0

There are 0 best solutions below