Automation for Jira - How to update the Request Participants or a multi user picker field from the content of other fields
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
If you are looking a solution for Jira Cloud, please refer instead to the KB article How to add/update/remove Request Participants using Automation for Jira
Summary
The Request Participants field is a custom field that comes from Jira Service Management that can contain multiple users. It is similar to a Multi User Picker field in Jira.
Configuring automation rules to update the Request Participants field (and any Multi User Picker field) based on the content of other fields and without overwriting its content can be quite challenging.
The purpose of this knowledge article is to provide some examples or automation rules to achieve this goal, based different scenarios.
If you are trying to write an automation rule to update a Multi User Picker field instead of the Request Participants field, you can also use the rules described in this KB article, since both types of field can be updated the exact same way.
All you have to do is replace Request Participants in any code block below with the name of the Multi User Picker field.
Environment
- Jira Server / Data Center 8.0.0 and any higher version
- Automation for Jira 7.4.0 and any higher version
Scenarios
List of scenarios:
- Scenario 1 - Add users to the Request Participants field using specific users
- Scenario 2 - Add users to the the Request Participants field using Single User Picker fields
- Scenario 3 - Add users to the Request Participants field using Multi User Picker fields
- Scenario 4 - Add users to the Request Participants field using a mix of Multi User Picker and Single User fields
- Scenario 5 - Add users to the Request Participants field from a field of type "Participants of an issue"
- Scenario 6 - Add users to the Request Participants field from a comments where users were mentioned
- Scenario 7 - Remove users from the Request Participants field
Scenario 1 - Add users to the Request Participants field using specific users
If all you need to do is update the Request Participants field by adding specific users, what you can do is:
- Use the Edit issue action
- Select Request Participants in Choose Fields to set...
Make sure to include the smart value below, otherwise any existing user in the Request Participants field will be deleted by this action. You can do it by copying/pasting the content below and taping the enter key. The text will be automatically detected as a Smart Value:
{{issue.Request Participants}}
- Then put the list of users you want to add to the Request Participants field
The automation rule will look like the rule illustrated in the screenshot below, assuming that you are trying to add 2 specific users (called "Customer1" and "Customer2") to the field:
Scenario 2 - Add users to the the Request Participants field using Single User Picker fields
For this use case, what you can do is:
- Use the Edit issue action
- Select Request Participants in Choose Fields to set...
Make sure to include the smart value below, otherwise any existing user in the Request Participants field will be deleted by this action. You can do it by copying/pasting the content below and taping the enter key. The text will be automatically detected as a Smart Value:
{{issue.Request Participants}}
Then add the list of Single User Picker fields from which you want to copy the user to the Request Participants field, using the Smart Value syntax shown below (make sure to replace "Field Name" with the actual name of the User picker field:
{{issue.Field Name}}
The automation rule will look like the rule illustrated in the screenshot below, assuming that you are trying to copy the users from 2 Single User Picker fields, and that the name of these fields are "Single User Picker" and "Single User Picker 2":
Scenario 3 - Add users to the Request Participants field using Multi User Picker fields
Solution 1
It is important to note that, when using Multi User Picker fields, the solution provide above for Single User Picker field will not work. The solution that needs to be implemented for this scenario is different and described below.
This solution consists in adding as many Edit Issues blocks as Multi User picker fields you need to merge into the Request Participants field, and for each of block, use the option Copy from current issue, and also make sure to tick the option Add to existing values, as shown in the screenshot below:
Additionally, you will need to add the block Re-fetch issue data between each Edit Issue block. This action will force the automation rule to reload the issue field data, and to fetch the most up to date content of the Request Participants field before updating is again. If the block Re-fetch issue data is not added, each Edit Issue block will overwrite the changes made by the previous Edit Issue block.
The automation rule will look like the rule illustrated in the screenshot below, assuming that you are trying to copy the users from 2 Multi User Picker fields:
Solution 2
An alternative option is to use only 1 single Edit Issue block, and instead of choosing the Request Participants field in the Choose field to set... dropdown, scroll down to Additional fields, and use a JSON formula similar to the one below:
{
"update": {
"Request participants": [
{{#issue.Multi user picker list}}{"add": {"name":"{{name}}"}}{{^last}},{{/}}{{/}},
{{#issue.Multi user picker list 2}}{"add": {"name":"{{name}}"}}{{^last}},{{/}}{{/}}
]
}
}
For this JSON formula to work for you, you will need to replace "Multi user picker list" and "Multi user picker list 2" with the actual names of the Multi User Picker fields from your Jira instance.
The automation rule will look like the rule illustrated in the screenshot below:
Scenario 4 - Add users to the Request Participants field using a mix of Multi User Picker and Single User fields
If you need to combine users from both single user and multi user picker fields in one go (by only using 1 block), what you can do is use the Edit Issue block, scroll down to Additional fields, and use a JSON formula similar to the one below:
{
"update": {
"Request participants": [
{{#issue.Multi user picker list}}{"add": {"name":"{{name}}"}}{{^last}},{{/}}{{/}},
{{#issue.Multi user picker list 2}}{"add": {"name":"{{name}}"}}{{^last}},{{/}}{{/}},
{
"add": {"name":"{{issue.Single User Picker}}"}
},
{
"add": {"name":"{{issue.Single User Picker 2}}"}
}
]
}
}
For this JSON formula to work for you, you will need to replace all the field names with the actual names of the Single and Multi User Picker fields from your Jira instance.
The automation rule will look like the rule illustrated in the screenshot below:
If you need to completely overwrite the Request Participants field and delete the users that were already in that field, you can use instead the JSON formula below:
Scenario 5 - Add users to the Request Participants field from a field of type "Participants of an issue"
If you need update the Request Participants field (and any type of multi user picker fields) by adding users coming from a field of type Participants of an issue (which comes from the Atlassian Lab add-on Toolkit plugin for Jira), you need to follow the steps listed below:
- Identify the ID of the Custom Field of type Participants of an issue by going to the page ⚙ > Issues > Custom Fields, trying to Edit the field, and picking up its ID from the URL shown in the browser
In the automation rule, add an Edit Issue block, scroll down to Additional fields, and use a JSON formula similar to the one below, after replacing XXXXX with the ID of the field of type Participants of an issue
{ "update": { "Request participants": [ {{#issue.customfield_XXXXX.substringBefore("(")}}{"add": {"name":"{{.}}"}}{{^last}},{{/}}{{/}} ] } }
The field of type Participants of an issue if a calculated field which comes from an add-on, and is therefore completely different from the Request Participants field and should not be confused with it.
If you need to completely overwrite the Request Participants field and delete the users that were already in that field, you can use instead the JSON formula below:
Scenario 6 - Add users to the Request Participants field from a comments where users were mentioned
If it possible update the Request Participants field (and any type of multi user picker fields) by adding users that were mentioned in a comment.
Let's assume that the users will be mentioned in a comment, and that the users will be separated by either the "-", "," or ";" character, as shown in the example of Jira comment below:
[~julien1]-[~julien2];[~julien3],[~julien4]
It is possible to use the split() function by listing in it all the delimiters that users might use when they mention several users.
If the users will be separated by either the "-", "," or ";" characters, then you can use split("[-,;]") inside the JSON formula, as shown in the steps below:
- Add the Edit Issue action
Scroll down to Additional fields, and use a JSON formula below:
{ "update": { "Request Participants": [ {{#issue.comment.last.body.split("[-,;]").substringAfterLast("[~").substringBeforeLast("]")}}{"add": {"name":"{{.}}"}}{{^last}},{{/}}{{/}} ] } }
Note that is users will be separated by a line break, then you will need to replace the split function in the example above with split("\n").
Scenario 7 - Remove users from the Request Participants field
It is possible to remove users from the Request Participants field (and any type of multi user picker fields), by using "update" → "remove" in the JSON formula.
Let's assume that you are trying to remove the user of the assignee field from the Request Participants field. To do that you can:
- Add the Edit Issue action
Scroll down to Additional fields, and use a JSON formula below:
{ "update": { "Request Participants": [ {"remove" : {"name": "{{issue.assignee.name}}"}} ] } }