Automation rule to copy users associated with a project role into a multi user picker field
プラットフォームについて: Cloud のみ - この記事は クラウド プラットフォームのアトラシアン製品に適用されます。
要約
This KB outlines the steps to configure an automation rule to copy users associated with a project role into a multi user picker field.
環境
Jira Cloud
ソリューション
Pre-requisite:
- 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 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 the trigger as 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.
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:
{
"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.