Copy users in a project role to a multi-user picker field using Automation
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
If you wish to take the list of users associated with a project role, and have those users selected in a multi-user picker field, you can copy them into the field using a Jira automation rule.
Solution
Prerequisites and setup steps
Create a custom field of type User Picker (multiple users) and add it to the screens associated with the required issue types
Make a note of the custom field ID to use in the automation rule
Get the ID of the required project role using the REST API endpoint Get all project roles
Configure and save an API token to be used in this rule
Encode the above API token along with the associated email in base64 per our guide
Let's assume 10002 is the ID assigned to the Administrators project role, and the requirement is to update the user picker custom field with the associated users. Our rule will only run in a single project, though you can run it as a global rule if you prefer.
Create the automation rule
Navigate to your project, select Project settings > Automation > Create rule
Trigger: Manual
You can choose any other triggers based on your requirements
Action - Send web request: Update the fields as below
Web request URL:
https://<your_site>.atlassian.net/rest/api/3/project/{{projectid}}/role/10002
HTTP method: GET
Web request body: Empty
Check the box "Delay execution of subsequent rule actions until we've received a response for this web request"
Headers:
Content-Type: Application/JSON
Authorization: <
base64_API_credentials>
Action - Edit work item: Choose More Options to edit the issue through Advanced field editing
Add the below JSON:
{ "fields": { "customfield_xxxxx": [ {{#webResponse.body.actors.actorUser}} { "accountId": "{{accountId}}" } {{^last}},{{/last}} {{/webResponse.body.actors.actorUser}} ] } }
Note: replace customfield_xxxxx
with the correct value associated with your multi user picker custom field.
Was this helpful?