Work with Users
With HAPI, we've made it easy for you to work with users.
Running code as another user
You can run code as another user with the Users
top-level object. For example, you may wish to create an issue in a post-function in a project that the current user may not have create issue permissions in.
Run the following script from the script console:
In this example we're creating an issue as another user.
Creating and modifying users
With HAPI we've made it easy for you to create and modify users.
Create a new user
You can create a user as follows:
You can control the user creation process further by specifying a closure:
In this example we're creating a user and adding a password, directory ID and application access.
Delete a user
You can delete a user as follows:
Deactivate and activate a user
You can deactivate or activate a user as follows:
User permissions and role membership
Extension methods on com.atlassian.jira.user.ApplicationUser
make it easy to:
- Retrieve whether the user has a given permission in a project
- Retrieve whether the user has a given global permission
- Retrieve whether the user has a particular project role membership in a project
Retrieving project permissions
You can retrieve project permissions as follows:
Retrieving issue permissions
You can retrieve issue permissions as follows:
Working with role memberships
You can work with role memberships as follows:
Working with group membership
You can work with group memberships as follows:
For more information on working with groups, see this page.