Automation for Jira - How to update the Request Participants or a multi user picker field from the content of other fields

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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

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.

It can be quite challenging to configure automation rules to update the Request Participants field (and any Multi User Picker field) based on the content of other fields without overwriting its content.

This knowledge article provides some examples or automation rules based on different scenarios to achieve this goal.

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.

Solution

Scenarios

List of scenarios:

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 tapping the enter key. The text will be automatically detected as a Smart Value:

    1 {{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 1 : Edit issue action

Scenario 2 - Add users to 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 tapping 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 is "Single User Picker" and "Single User Picker 2":

Scenario 2 - automation rule

Scenario 3 - Add users to the Request Participants field using Multi-User Picker fields

Solution 1

It is important to note that the solution provided above for the Single User Picker field will not work when using multi-user picker fields. The solution that needs to be implemented for this scenario is different and described below.

This solution consists of adding as many Edit Issues blocks as Multi-User picker fields you need to merge into the Request Participants field, and for each 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:

Choose add to existing values

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 fetch the most up-to-date content of the Request Participants field before updating it 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:

Screenshot of the automation rule

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:

1 2 3 4 5 6 7 8 { "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, 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:

Automation rule screenshot

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 { "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, 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:

Rule screenshot

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 { "fields": { "Request participants": [ {{#issue.Multi user picker list 1}}{"name":"{{name}}"}{{^last}},{{/}}{{/}}, {{#issue.Multi user picker list 2}}{"name":"{{name}}"}{{^last}},{{/}}{{/}}, { "name": "{{issue.Single User Picker}}" }, { "name": "{{issue.Single User Picker 2}}" } ] } }

Scenario 5 - Add users to the Request Participants field from a field of type "Participants of an issue"

If you need to 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.

    1 2 3 4 5 6 7 { "update": { "Request participants": [ {{#issue.customfield_XXXXX.substringBefore("(")}}{"add":{"name":{{.}}"}}{{^last}},{{/}}{{/}} ] } }

The field of type Participants in an issue is a calculated field that 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:

1 2 3 4 5 6 7 { "fields": { "Request Participants": [ {{#issue.customfield_XXXXX.substringBefore("(")}}{"name":"{{.}}"}{{^last}},{{/}}{{/}} ] } }

Scenario 6 - Add users to the Request Participants field from 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 the JSON formula below:

1 2 3 4 5 6 7 8 9 10 { "update": { "Request Participants": [ {{#issue.comment.last.body.split("[-,;]").substringAfterLast("[~").substringBeforeLast("]")}}{"add": {"name":"{{.}}"}}{{^last}},{{/}}{{/}} ] } }

Note that if users are 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 the JSON formula below:

    1 2 3 4 5 6 7 8 9 10 { "update": { "Request Participants": [ {"remove" : {"name": "{{issue.assignee.name}}"}} ] } }

Updated on June 13, 2024

Still need help?

The Atlassian Community is here for you.