Can anyone advice me on how I can use ScriptRunner's built-in script to make it so that:
I have a scripted Behaviour already, but want to enforce it with a validator to make sure no one else accidentally get to create a Bug ticket (per guidance from here: https://docs.adaptavist.com/sr4js/6.33.0/features/behaviours/behaviours-examples/restricting-issue-types)
All other documentations on the ScriptRunner KB doesn't cover this specific scenarios. Any thoughts would be appreciate it. Thank you!
A "simple scripted validator" on your create transition can accomplish that.
import com.atlassian.jira.component.ComponentAccessorComponentAccessor.groupManager.isUserInGroup(currentUser, 'Security')
Note: currentUser is already defined in a simple scripted validator.
And the last line will return true/false. If it returns false, the validator fails and the message you specify in the "Error Message" field will be displayed.
Hi Peter. Thanks for providing an insight on this. Is it possible for the script to only conditionally target a specific issue type?
Basically, I have 1 workflow behind 2 issue types (Say Bug and Task) and I only want this logic to apply to issue type Bug, and Task remains open for anyone to use.
sure... that's quite simple:
import com.atlassian.jira.component.ComponentAccessordef restrictedIssueTypes = ['Bug', 'Defect']if(!restrictedIssueTypes.contains(issue.issueType.name)){ return true}ComponentAccessor.groupManager.isUserInGroup(currentUser, 'Security')
It looks like you're new here. Sign in or register to get started.