Snippets

Adaptavist Adaptavist ScriptRunner for Jira Cloud Example Workflow Validators

Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 // Specify that the description field must contain more than 30 characters
 // Note the plainText paramater matches the comment as plain text but you can match it as Rich Text if needed by changing the paramater to RichText
 issue.description.plainText.length >30 // You may also want to set the Error message to have text similar to 'The description field must contain more than 30 characters.'
+
+// Specify that the issue must be in an active sprint
+issue.sprint.state == 'active' // You may also want to set the Error message to have text similar to 'This issue must be in a valid Sprint.'
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 // Speicify that at least one linked issue must be entered when the issue is created 
 issue.links.length >0 // You may also want to set the Error message to have text similar to 'You must specify at least one linked issue in order to be able to create this issue.'
 
-// Specify that at least one fix version is added to the issue when it is created
-issue.fixVersions.length >0 // You may also want to set the Error message to have text similar to 'You must specify at least one fix version in order to be able to create this issue.'
+// Specify that at least one Fix Version is added to the issue when it is created
+issue.fixVersions.length >0 // You may also want to set the Error message to have text similar to 'You must specify at least one Fix Version in order to be able to create this issue.'
+
+// Specify that at least one Component is added to the issue when it is created
+issue.components.length >0 // You may also want to set the Error message to have text similar to 'You must specify at least one Component in order to be able to create this issue.'
 
 // Specify that both select list drop downs in a custom cascading select field must be populated in order to create an issue. 
 // Note: You should replace 'customfield_10093' in the example below with the ID of the cascading select list field inside of your instance. 
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 // Speicify that at least one linked issue must be entered when the issue is created 
 issue.links.length >0 // You may also want to set the Error message to have text similar to 'You must specify at least one linked issue in order to be able to create this issue.'
 
+// Specify that at least one fix version is added to the issue when it is created
+issue.fixVersions.length >0 // You may also want to set the Error message to have text similar to 'You must specify at least one fix version in order to be able to create this issue.'
+
 // Specify that both select list drop downs in a custom cascading select field must be populated in order to create an issue. 
 // Note: You should replace 'customfield_10093' in the example below with the ID of the cascading select list field inside of your instance. 
 issue.customfield_10093.child.value.length >0 // You may also want to set the Error message to have text similar to 'You must specify a value in both of the Cascading Select List field drop downs in order to be able to create this issue.'
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 issue.subtasks.filter(subtask => subtask.status.name == 'In Progress').length == issue.subtasks.length // You may also want to set the Error message to have text similar to 'All subtasks must be in the In Progress status before this parent issue can be transitioned.'
 
 // Specify that the description field must contain more than 30 characters
+// Note the plainText paramater matches the comment as plain text but you can match it as Rich Text if needed by changing the paramater to RichText
 issue.description.plainText.length >30 // You may also want to set the Error message to have text similar to 'The description field must contain more than 30 characters.'
Updated by Kristian Walker

File ScriptRunnerforJiraCloudExampleWorkflowValidatorss.groovy Modified

  • Ignore whitespace
  • Hide word diff
 issue.customfield_10093.child.value.length >0 // You may also want to set the Error message to have text similar to 'You must specify a value in both of the Cascading Select List field drop downs in order to be able to create this issue.'
 
 // Specify that All Sub Tasks must be in the 'In Progress' status before the parent issue can be transitioned
-issue.subtasks.filter(subtask => subtask.status.name == 'In Progress').length == issue.subtasks.length // You may also want to set the Error message to have text similar to 'All subtasks must be in the In Progress status before this parent issue can be transitioned.'
+issue.subtasks.filter(subtask => subtask.status.name == 'In Progress').length == issue.subtasks.length // You may also want to set the Error message to have text similar to 'All subtasks must be in the In Progress status before this parent issue can be transitioned.'
+
+// Specify that the description field must contain more than 30 characters
+issue.description.plainText.length >30 // You may also want to set the Error message to have text similar to 'The description field must contain more than 30 characters.'
  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.