...
Info | ||
---|---|---|
| ||
This routine is available since starting with katl-commons 2.0.6 ( for JIRA Jira 5.x ) or katl-commons 1.1.13 ( for JIRA Jira 4.3.x and /4.4.x) |
Syntax
...
hasPermission(permissionId, user[, issueKey])
Description
...
Excerpt |
---|
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 |
issueKey | String | No | The issue key. Only required for non-global permissions. |
...
Category | Permissions | Description | ID |
---|---|---|---|
Global Permissions | JIRA Administrators | Ability to perform most administration functions (excluding Import & Export, SMTP Configuration, etc.). | 0 |
Bulk Change | Ability to modify a collection of issues at once. For example, resolve multiple issues in one step. | 33 | |
Create Shared Objects | Ability 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 Administrators | Ability to perform all administration functions. There must be at least one group with this permission. | 44 | |
JIRA Users | Ability 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 Users | Ability 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 Projects | Ability to administer a project in JIRA. | 23 |
Browse Projects | Ability to browse projects and the issues within them. | 10 | |
View Version Control | Ability 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 Issues | Ability to assign issues to other people. | 13 | |
Assignable User | Users with this permission may be assigned to issues. | 17 | |
Close Issues | Ability to close issues. Often useful where your developers resolve issues, and a QA department closes them. | 18 | |
Create Issues | Ability to create issues. | 11 | |
Delete Issues | Ability to delete issues. | 16 | |
Edit Issues | Ability to edit issues. | 12 | |
Link Issues | Ability to link issues together and create linked issues. Only useful if issue linking is turned on. | 21 | |
Modify Reporter | Ability to modify the reporter when creating or editing an issue. | 30 | |
Move Issues | Ability 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 Issues | Ability to resolve and reopen issues. This includes the ability to set a fix version. | 14 | |
Schedule Issues | Ability to set or edit an issue's due date. | 28 | |
Set Issue Security | Ability to set the level of security on an issue so that only people in that security level can see the issue. | 26 | |
Manage Watchers | Ability to manage the watchers of an issue. | 32 | |
View Voters and Watchers | Ability to view the voters and watchers of an issue | 31 | |
Delete All Comments | Ability to delete all comments made on issues. | 36 | |
Delete Own Comments | Ability to delete own comments made on issues. | 37 | |
Edit All Comments | Ability to edit all comments made on issues. | 34 | |
Edit Own Comments | Ability to edit own comments made on issues. | 35 | |
Add Comments | Ability to comment on issues. | 15 | |
Delete All Attachments | Users with this permission may delete all attachments. | 38 | |
Delete Own Attachments | Users with this permission may delete own attachments. | 39 | |
Create Attachments | Users with this permission may create attachments. | 19 | |
Work On Issues | Ability to log work done against an issue. Only useful if Time Tracking is turned on. | 20 | |
Delete All Worklogs | Ability to delete all worklogs made on issues. | 43 | |
Delete Own Worklogs | Ability to delete own worklogs made on issues. | 42 | |
Edit All Worklogs | Ability to edit all worklogs made on issues. | 41 | |
Edit Own Worklogs | Ability 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
...
Code Block |
---|
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. |
...
Code Block |
---|
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
Filter by label (Content by label) | ||||||||
---|---|---|---|---|---|---|---|---|
|