Snippets

Adaptavist Adaptavist ScriptRunner for Jira Cloud Example Workflow Validators

Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 // Validate that a checkbox custom field contains a specic value  as an option and that a single line text field is not empty
 // Note: You should replace 'customfield_12345' in the example below with the ID of the checkbox field and should replace "A" with the option value to validate against
 // Note: You should replace 'customfield_56789' in the example below with the ID of the single line text field that must not be empty
-issue.customfield_12345.map(c => c.value).filter(value => value == "A").length > 0 && issue.customfield_56789 != null
+issue.customfield_12345.map(c => c.value).filter(value => value == "A").length > 0 && issue.customfield_56789 != null
+
+// 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'
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 // Note: You should replace 'customfield_12345' in the example below with the ID of the checkbox field and should replace "A" with the option value to validate against
 // Note: You should replace 'customfield_56789' in the example below with the ID of the single line text field that must not be empty
 issue.customfield_12345[0].value =="A" && issue.customfield_12345.length ==1 && issue.customfield_56789 != null
+
+// Validate that a checkbox custom field contains a specic value  as an option and that a single line text field is not empty
+// Note: You should replace 'customfield_12345' in the example below with the ID of the checkbox field and should replace "A" with the option value to validate against
+// Note: You should replace 'customfield_56789' in the example below with the ID of the single line text field that must not be empty
+issue.customfield_12345.map(c => c.value).filter(value => value == "A").length > 0 && issue.customfield_56789 != null
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 // Validate that one of two label fields must have a value 
 // Note: You should replace 'customfield_12345' and 'customfield_12346' in the example below with the ID's of the label fields inside of your instance. 
 issue.customfield_12345 !=null || issue.customfield_12346 !=null //You may also want to set the Error message to have text similar to 'You must specify a value in one of the label fields'
-
 // Validate that a checkbox custom field only has one value set which is of a specic value
 // Note: You should replace 'customfield_12345' in the example below with the ID of the checkbox field and should replace "A" with the option value to validate against
 issue.customfield_12345[0].value =="A" && issue.customfield_12345.length ==1 //You may also want to set the Error message to have text similar to 'You must specify the value of <Value Here> only in the checkbox field'
+
+// Validate that a checkbox custom field only has one value set which is of a specic value and that a single line text field is not empty
+// Note: You should replace 'customfield_12345' in the example below with the ID of the checkbox field and should replace "A" with the option value to validate against
+// Note: You should replace 'customfield_56789' in the example below with the ID of the single line text field that must not be empty
+issue.customfield_12345[0].value =="A" && issue.customfield_12345.length ==1 && issue.customfield_56789 != null
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 
 
 // Validate that one of two label fields must have a value 
-// Note: You should replace 'customfield_10099' and 'customfield_10100' in the example below with the ID's of the label fields inside of your instance. 
-issue.customfield_10099 !=null || issue.customfield_10100 !=null //You may also want to set the Error message to have text similar to 'You must specify a value in one of the label fields'
-
-
+// Note: You should replace 'customfield_12345' and 'customfield_12346' in the example below with the ID's of the label fields inside of your instance. 
+issue.customfield_12345 !=null || issue.customfield_12346 !=null //You may also want to set the Error message to have text similar to 'You must specify a value in one of the label fields'
 
+// Validate that a checkbox custom field only has one value set which is of a specic value
+// Note: You should replace 'customfield_12345' in the example below with the ID of the checkbox field and should replace "A" with the option value to validate against
+issue.customfield_12345[0].value =="A" && issue.customfield_12345.length ==1 //You may also want to set the Error message to have text similar to 'You must specify the value of <Value Here> only in the checkbox field'
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 issue.issueType.name.match('^(<IssueTypeHere>)$') != null && user.getProjectRoles(project).map(p => p.name).includes("<ProjectRoleHere>") || issue.issueType.name.match('^(<IssueTypeHere>|<IssueTypeHere>)$') != null //You may also want to set the Error message to have text similar to 'You must be in the X Project Role to create the X Issue Type'
 
 
+// Validate that one of two label fields must have a value 
+// Note: You should replace 'customfield_10099' and 'customfield_10100' in the example below with the ID's of the label fields inside of your instance. 
+issue.customfield_10099 !=null || issue.customfield_10100 !=null //You may also want to set the Error message to have text similar to 'You must specify a value in one of the label fields'
 
 
 
  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.