Forums

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

ScriptRunner Workflow Validation

Yevgeniy Pinchuk
Contributor
January 23, 2024

Hi all,

Could use some guidance on creating a workflow validation in ScriptRunner. I am fairly technical but scripting is pretty new to me and after hours of trying to decipher the documentation I am close to giving up.

Basically, I need a script that:
1. validates that if issue type = 'incident' and
2. regression status includes one of three statuses (Last Release Regression, Previous Release Regression, RC Regression) that indicates that this is in fact a regression,
3, upon transition to 'in review' status
4. I want to require the user to fill out a multi-line 'root cause' field

Any help with the syntax would be greatly appreciated!

Cheers

1 answer

1 accepted

1 vote
Answer accepted
Bobby Bailey
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.
January 24, 2024

Hi @Yevgeniy Pinchuk ,

With Cloud, ScriptRunner for Jira uses Jira Expressions. You may have already seen this link on how to build Expression queries: https://developer.atlassian.com/cloud/jira/platform/jira-expressions/

But in my opinion, the most useful one is actually at the bottom of that page, and its this one: https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference/

This shows you how the data is stored and how you can access it. So, for example, for your first condition, I can use that page to discover that the issue type string is stored under: 

'issue.issueType.name'

Then we can build the first part of your query: 

issue.issueType.name == 'incident'

OR we can assign it to the id which is more reliable: 

issue.issueType.id == [YOUR ID HERE].

 

For your other conditions: 

- For regression status, Custom fields can be accessed like this: issue.customfield_XXXXX.
- If you want this validator to execute on transition to 'on review', you will have to create this validator on that transition

- Again you can access this custom field using the same accessor as above, and check that it is not empty. 

Does this help?

Kind regards, 

Bobby

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events