There are a lot of old answers out there and only a few obscure answers using the current API
https://community.atlassian.com/t5/Answers-Developer-Questions/Script-Runner-Post-Function-Permission-Checking/qaq-p/542213 is the old answer and it would be so cool to be able to just add a new answer.
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.security.plugin.ProjectPermissionKeydef permissionManager = ComponentAccessor.getPermissionManager()def hasPerm = permissionManager.hasPermission(new ProjectPermissionKey("TRANSITION_ISSUES"), issue, currentUser)
The list of permissions is in https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/permission/ProjectPermissions.html
This works in conditions and validators
Hallo Martina,
I am unfortunately a beginner in groovy/java and can't get the code snippet to run.I get the error "cant find matching method: ProjectPermissionKey" when I run it in ScriptRunner Console.
def currentUser = 'User1'def issue = 'Test-1'import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.security.plugin.ProjectPermissionKeydef permissionManager = ComponentAccessor.getPermissionManager()def hasPerm = permissionManager.hasPermission(ProjectPermissionKey("TRANSITION_ISSUES"), issue, currentUser)//"ADD_COMMENTS"
What am I doing wrong?
Gruß Thomas
Issue isn't just a string. In conditions and Validators it's properly set. In the console you have to get the issue object yourself.
see getIssueObject('your Issue ID')
If you want this for a condition or validator, I just create a simple condition and do previews and asserts right in there to get it right.
just found an example where I get an issue in teh Console:
def issueManager = ComponentAccessor.issueManagerdef issue = issueManager.getIssueByCurrentKey(issueKey)
It looks like you're new here. Sign in or register to get started.