I've tried several examples that I've found for Scriptrunner but can't seem to get something to work. I want to set a validator on a sub-task with "Code review" in the summary and a user is in a project role. Some of the code I found has underlyingIssue in it but my jira doesn't seem to recognize it. I've tried this IF:
if (issue.getSummary().equals("Code review") && (groupManager.isUserInGroup(currentUser, "Dev Lead")))
and
if (projectRoleManager.isUserInProjectRole(currentUser, devProjectRole, underlyingIssue.getProjectObject()))
I'm using Script Validator (Scriptrunner) and we are using Jira 8.1.0.
Thanks for your time!
~jeff
Hey @Jeff Foege ,
Can you try changing underlyingIssue.getProjectObject() to issue.getProjectObject() instead?
I configured the script in my Validator and was able to get the error to appear if the user is not in the Administrator role:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def adminRole = projectRoleManager.getProjectRole('Administrators')
if(issue.getSummary().equals("Code Review") && projectRoleManager.isUserInProjectRole(currentUser, adminRole, issue.getProjectObject())) {
return true
} else {
return false
}
Hope this helps.
Regards.
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.