Automation rule to copy users in a project role into a multi-user picker field
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
This KB outlines the steps to configure an automation rule to copy users associated with a project role into a multi user picker field.
Environment
Jira Cloud
Solution
Pre-requisite:
Create a custom fieldof typeUser Picker (multiple users)andadd itto the screens associated with the required issue types. Make a note of the custom field ID to use it in the Advanced field editing.
Get the ID of the required project role using the Get all project roles.
Lets consider 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.
Automation Rule Configuration:
Trigger: Choose thetriggeras per your requirement.
Condition:Add a condition to check issue types if required
Actions:
Action 1: Create Variable: If it's a Global rule, create a variable to capture the project ID for later use. (Example: Variable name "projectid" for smart value {{issue.project.id}}).
Action 2: Send web request: Update the fields as below
Web request URL: https://<sitename>.atlassian.net/rest/api/3/project/{{projectid}}/role/10002
HTTP method: GET
Web request body: Empty
Ensure to select "Delay execution of subsequent rule actions until we've received a response for this web request"
Headers (optional)
Content-Type: Application/JSON
Authorization: <EMAIL>:<API_TOKEN> encoded in base64
Refer to Automation for Jira - Send web request using Jira REST API for the steps to encode credentials
Action 3: Edit Issue
Choose More Options to edit the issue through Advanced field editing. Add the below JSON:
1
2
3
4
5
6
7
8
9
10
11
12
{
"fields": {
"customfield_xxxxx": [
{{#webResponse.body.actors.actorUser}}
{
"accountId": "{{accountId}}"
}
{{^last}},{{/last}}
{{/webResponse.body.actors.actorUser}}
]
}
}
Note: customfield_xxxxx is the id of the multi user picker custom field.
Was this helpful?