Snippets

Adaptavist Adaptavist ScriptRunner for Jira Cloud Example Workflow Validators

Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
     true
     
 // Validate an issue must have at least one issue blocking it with the 'is blocked by link' and its resolution must not be set
-issue.links.some(l => l.type.inward == 'is blocked by') && issue.resolution == null
+issue.links.some(l => l.type.inward == 'is blocked by' && l.linkedIssue.resolution == null)
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
     true
     
 // Validate an issue must have at least one issue blocking it with the 'is blocked by link' and its resolution must not be set
-issue.links.some(l => l.type.outward == 'blocks' && l.linkedIssue.resolution == null)
+issue.links.some(l => l.type.inward == 'is blocked by') && issue.resolution == null
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 // Note: You should replace 'customfield_10138' in the example below with the ID of the single select list field that must not be empty
 issue.issueType.name == 'sub-task' ? 
     issue.customfield_10138 != null : 
-    true
+    true
+    
+// Validate an issue must have at least one issue blocking it with the 'is blocked by link' and its resolution must not be set
+issue.links.some(l => l.type.outward == 'blocks' && l.linkedIssue.resolution == null)
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 
 // All child issues below an epic except for Bugs must be done before the Epic can be transitioned
 //You may also want to set the Error message to have text similar to 'All child issues below an epic except for Bugs must be done before the Epic can be transitioned.'
-issue.isEpic && issue.stories.every(story => (story.issueType.name == 'Bug' && story.status.name != 'Done') || (story.issueType.name != 'Bug' && story.status.name == 'Done') )
+issue.isEpic && issue.stories.every(story => (story.issueType.name == 'Bug' && story.status.name != 'Done') || (story.issueType.name != 'Bug' && story.status.name == 'Done') )
+
+// validate that a select list custom field is required when a sub-task of type'sub-task' is created
+// Note: You should replace 'customfield_10138' in the example below with the ID of the single select list field that must not be empty
+issue.issueType.name == 'sub-task' ? 
+    issue.customfield_10138 != null : 
+    true
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 
 // Priority must have a value and must not have the value Highest
 //You may also want to set the Error message to have text similar to 'You are not permitted to select the Highest Priority'
-issue.priority != null && issue.priority.name != 'Highest'
+issue.priority != null && issue.priority.name != 'Highest'
+
+// All child issues below an epic except for Bugs must be done before the Epic can be transitioned
+//You may also want to set the Error message to have text similar to 'All child issues below an epic except for Bugs must be done before the Epic can be transitioned.'
+issue.isEpic && issue.stories.every(story => (story.issueType.name == 'Bug' && story.status.name != 'Done') || (story.issueType.name != 'Bug' && story.status.name == 'Done') )
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.