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.ComponentAccessor
ComponentAccessor.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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sure... that's quite simple:
import com.atlassian.jira.component.ComponentAccessor
def restrictedIssueTypes = ['Bug', 'Defect']
if(!restrictedIssueTypes.contains(issue.issueType.name)){
return true
}
ComponentAccessor.groupManager.isUserInGroup(currentUser, 'Security')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.