Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table plus
applyColStyleToCelltrue
heading0
columnTypess,s,s,s
multiplefalse
columnAttributesstyle="background:#e5e7ea;font-weight:bold,,style="background:#e5e7ea;font-weight:bold,
enableSortingfalse

Syntax

hasPermission(permissionId, user[, issueKey])

Package

Alias

Pkg Usage

Description

Excerpt
hiddentrue
Checks if a user has the specified permission.

Checks if a user has the specified permission.

Parameters

Table plus
applyColStyleToCelltrue
columnTypess,s,s,s
heading0
multiplefalse
enableSortingfalse

Parameter name

Type

Required

Description

permissionId

Number

Yes

Permission ID.

user

String

Yes

Username or userkey to check the permission for.

issueKey

String

No

Issue key. Only required for non-global permissions.

Return Type

Boolean

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

Examples

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

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; 
	} 
}

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.

See also

Filter by label (Content by label)
showLabelsfalse
max25
showSpacefalse
cqllabel = "user_routine" and space = currentSpace ( )
labelsarray_routines