Skip to end of banner
Go to start of banner

hasPermission

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Availability

This routine is available starting with katl-commons 2.0.6 for Jira 5.x or katl-commons 1.1.13 for Jira 4.3.x/4.4.x

Syntax

hasPermission(permissionId, user[, issueKey])

Description

Checks if a user has the specified permission

Parameters

Parameter name

Type

Required

Description

permissionId

Number

Yes

The permission ID.

user

String

Yes

The username or userkey to check the permission for

issueKeyStringNoThe issue key. Only required for non-global permissions.

Permissions

CategoryPermissionsDescriptionID
Global PermissionsJIRA AdministratorsAbility to perform most administration functions (excluding Import & Export, SMTP Configuration, etc.).0
Bulk ChangeAbility to modify a collection of issues at once. For example, resolve multiple issues in one step. 33
Create Shared ObjectsAbility to share dashboards and filters with other users, groups and roles. 22

Manage Group Filter Subscriptions

Ability to manage (create and delete) group filter subscriptions.24
JIRA System AdministratorsAbility to perform all administration functions. There must be at least one group with this permission.44
JIRA UsersAbility to log in to JIRA. They are a 'user'. Any new users created will automatically join these groups, unless those groups have JIRA System Administrators or JIRA Administrators permissions. 1
Browse UsersAbility to select a user or group from a popup window as well as the ability to use the 'share' issues feature. Users with this permission will also be able to see names of all users and groups in the system.27
Project Permissions  

 

           
Administer ProjectsAbility to administer a project in JIRA.23
Browse ProjectsAbility to browse projects and the issues within them. 10
View Version ControlAbility to view Version Control commit information for issues.29

View Read-Only Workflow

Users with this permission may view a read-only version of a workflow.45
Assign IssuesAbility to assign issues to other people.13
Assignable UserUsers with this permission may be assigned to issues. 17
Close IssuesAbility to close issues. Often useful where your developers resolve issues, and a QA department closes them. 18
Create IssuesAbility to create issues. 11
Delete IssuesAbility to delete issues. 16
Edit IssuesAbility to edit issues. 12
Link IssuesAbility to link issues together and create linked issues. Only useful if issue linking is turned on. 21
Modify ReporterAbility to modify the reporter when creating or editing an issue.30
Move IssuesAbility to move issues between projects or between workflows of the same project (if applicable). Note the user can only move issues to a project he or she has the create permission for. 25
Resolve IssuesAbility to resolve and reopen issues. This includes the ability to set a fix version.14
Schedule IssuesAbility to set or edit an issue's due date. 28
Set Issue SecurityAbility to set the level of security on an issue so that only people in that security level can see the issue. 26
Manage WatchersAbility to manage the watchers of an issue. 32
View Voters and WatchersAbility to view the voters and watchers of an issue31
Delete All CommentsAbility to delete all comments made on issues. 36
Delete Own CommentsAbility to delete own comments made on issues.37
Edit All CommentsAbility to edit all comments made on issues.34
Edit Own CommentsAbility to edit own comments made on issues.35
Add CommentsAbility to comment on issues. 15
Delete All AttachmentsUsers with this permission may delete all attachments. 38
Delete Own AttachmentsUsers with this permission may delete own attachments. 39
Create AttachmentsUsers with this permission may create attachments. 19
Work On IssuesAbility to log work done against an issue. Only useful if Time Tracking is turned on. 20
Delete All WorklogsAbility to delete all worklogs made on issues. 43
Delete Own WorklogsAbility to delete own worklogs made on issues.42
Edit All WorklogsAbility to edit all worklogs made on issues.41
Edit Own WorklogsAbility to edit own worklogs made on issues. 40

Transition Issues

Ability to transition issues.

46

 

Return type

boolean

Returns true if the user has the specified permission, or false otherwise.

Note

 This routine also verifies the issue security level. If the specified user cannot see the issue because his security level does not allow it, the routine will return false for the project permissions even if the user does have the specified privilege. This happens because the issue security comes first and will prohibit the user from taking actions that are otherwise allowed by the permission scheme.

The look-up is first made after the userkey, then after the username.

Example

Example 1

for(string user in usersInGroups({"QA-Testers"})){
	if(hasPermission(17, user, key)){
		assignee = user;
		return;
	}
} 

Result: The issue will be assigned to one of the testers who have the permission to be assigned issues on the current project.

Example 2

 

Tip

Attached to this page is permissions.incl which contains variable definitions for all the above permissions. You can upload this file to your JIRA instance via the SIL Manager, include it in your scripts and then use the variables defined there to make the code easier to understand.

 

Using permissions.incl, the above example becomes:

include "permissions.incl"; // assuming the file is in the default programs folder 
for(string user in usersInGroups({"QA-Testers"})){ 
	if(hasPermission(ASSIGNABLE_USER, user, key)){ 
		assignee = user; 
		return; 
	} 
} 

 

See also

  • No labels