Automation for Jira - Various methods to update a group picker (multiple groups) field
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
Summary
Updating the content of a group picker field (multiple groups) is not always an easy task, especially when using a JSON formula in an Edit Issue component.
The purpose of this knowledge article is to provide some examples or automation rules that can be used to update this type of field, using either:
- explicit values
- the content of single group picker fields
- the content of multi group picker fields
Environment
- Jira Server / Data Center 8.0.0 and any higher version
- Automation for Jira 7.4.0 and any higher version
Scenarios
For each scenario below, we will assume that the name of the custom field that we are trying to update is called Multi Group Picker. If the name of your field is different, please make sure to change it in all the scenarios provided below.
List of scenarios:
- Scenario 1 - Update the group picker (multiple groups) field with explicit values
- Scenario 2 - Update the group picker (multiple groups) field with the content of group picker (single group) fields
- Scenario 3 - Update the group picker (multiple groups) field with the content of other group picker (multiple groups) fields
Scenario 1 - Update the group picker (multiple groups) field with explicit values
Use Case 1
If you want to replace the content of the field with specific values, you have 2 options:
Solution 1
- Add the Edit Issue action
- Select the field to update using the option Choose the fields to set to
- Enter the options there, as shown in the screenshot below:
Solution 2
- Add the Edit Issue action
- Expand the More options setting
Use the JSON formula below (make sure to update it, based on the name of your field, and the values you want to add to it)
{ "fields": { "Multi Group Picker": [ { "name":"jira-administrators" }, { "name":"jira-software-users" } ] } }
Use Case 2
If you want to edit the field without overwriting its original content, you have 2 options:
Solution 1
- Add the Edit Issue action
- Select the field to update using the option Choose the fields to set to
- Enter the options there, in addition to the smart value {{issue.Multi Group Picker}} (make sure to replace "Multi Group Picker" with the name of your customer field), as shown in the screenshot below.
Adding this smart value will prevent the rule from deleting the original content.
Solution 2
- Add the Edit Issue action
- Expand the More options setting
Use the JSON formula below (make sure to update it, based on the name of your field, and the values you want to add to it)
{ "update": { "Multi Group Picker": [ {"add": { "name":"jira-administrators" }}, {"add": { "name":"jira-software-users" }} ] } }
Scenario 2 - Update the group picker (multiple groups) field with the content of group picker (single group) fields
Use Case 1
If you want to replace the content of the Multi Group Picker field with values coming from 2 group picker (single group) fields listed below, you have 2 options:
- Single Group Picker 1
- Single Group Picker 2
Solution 1
- Add the Edit Issue action
- Select the field to update using the option Choose the fields to set to
- Enter the list of options list below, as shown in the screenshot below (make sure to replace "Single Group Picker 1" and "Single Group Picker 2" with the actual group picker fields):
- {{issue.Single Group Picker 1}}
- {{issue.Single Group Picker 2}}
Solution 2
- Add the Edit Issue action
- Expand the More options setting
Use the JSON formula below (make sure to update it, based on the name of your fields):
{ "fields": { "Multi Group Picker": [ { "name":"{{issue.Single Group Picker 1.name}}" }, { "name":"{{issue.Single Group Picker 2.name}}" } ] } }
Use Case 2
If you want to edit the field without overwriting its original content, you have 2 options:
Solution 1
- Add the Edit Issue action
- Select the field to update using the option Choose the fields to set to
- Enter the list of options below, as shown in the screenshot below (make sure to replace "Single Group Picker 1" and "Single Group Picker 2" with the actual group picker fields):
- {{issue.Multi Group Picker}}
- {{issue.Single Group Picker 1}}
- {{issue.Single Group Picker 2}}
Solution 2
- Add the Edit Issue action
- Expand the More options setting
Use the JSON formula below (make sure to update it, based on the name of your fields):
{ "update": { "Multi Group Picker": [ {"add": {"name":"{{issue.Single Group Picker 1.name}}"}}, {"add": {"name":"{{issue.Single Group Picker 2.name}}"}} ] } }
Scenario 3 - Update the group picker (multiple groups) field with the content of other group picker (multiple groups) fields
Use Case 1
Let's assume that you want to replace the content of the Multi Group Picker field with values coming from 2 group picker (multi group) fields listed below:
- Multi Group Picker 1
- Multi Group Picker 2
Here is the solution:
- Add the Edit Issue action
- Select the field to update using the option Choose the fields to set to
- Enter the options below, as shown in the screenshot below (make sure to replace "Multi Group Picker 1" and "Multi Group Picker 2" with the actual group picker fields):
- {{issue.Multi Group Picker 1}}
- {{issue.Multi Group Picker 2}}
Use Case 2
If you want to edit the field without overwriting its original content, here is the solution:
- Add the Edit Issue action
- Select the field to update using the option Choose the fields to set to
- Enter the option below, as shown in the screenshot (make sure to replace all the field names with the ones from your Jira instance):
- {{issue.Multi Group Picker}}
- {{issue.Multi Group Picker 1}}
- {{issue.Multi Group Picker 2}}