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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.