Automation for Jira - How to update a select field (multiple choices) 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

Updating the content of a select field (multiple choices) based on the content of other fields is not always an easy task, especially when using a JSON formula.

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-choice select fields

  • the content of multiple-choice select fields

  • other types of fields, such as a text field

Solution

Scenarios

For each scenario below, we will assume that the name of the custom field that we are trying to update is Select List Multiple Choices. 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 select field (multiple choices) 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:

    Add data to multi-select field using automation

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)

    1 2 3 4 5 6 7 8 { "fields": { "Select List Multiple Choices": [ {"value" : "Option 1"}, {"value" : "Option 2"} ] } }

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.Select List Multiple Choices}}, as shown in the screenshot below. Adding this smart value will prevent the rule from deleting the original content.

    set select list multiple choice using automation

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)

    1 2 3 4 5 6 7 8 { "update": { "Select List Multiple Choices": [ {"add": {"value":"Option 1"}}, {"add": {"value":"Option 2"}} ] } }

Scenario 2 - Update the select field (multiple choices) with the content of select fields (single choice)

Use Case 1

If you want to replace the content of the field with values coming from 2 select fields (single choice), 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 list below, as shown in the screenshot below:

    • {{issue.Select List Single Choice 1}}

    • {{issue.Select List Single Choice 2}}

      Set single select multiple choice field using smart value using automation

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):

1 2 3 4 5 6 7 8 { "fields": { "Select List Multiple Choices": [ {"value":"{{issue.Select List Single Choice 1.value}}"}, {"value":"{{issue.Select List Single Choice 2.value}}"} ] } }

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:

    • {{issue.Select List Multiple Choices}}

    • {{issue.Select List Single Choice 1}}

    • {{issue.Select List Single Choice 2}}

      Select List multiple options using automation

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):

1 2 3 4 5 6 7 8 { "update": { "Select List Multiple Choices": [ {"add": {"value":"{{issue.Select List Single Choice 1.value}}"}}, {"add": {"value":"{{issue.Select List Single Choice 2.value}}"}} ] } }

Scenario 3 - Update the select field (multiple choices) with the content of another select field (multiple choices)

Use Case 1

If you want to replace the content of the field with values coming from another select field (multiple choices), 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 option {{issue.Select List Multiple Choices 2}}, as shown in the screenshot below:

    Select List Multiple choices using smart value in automation

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):

    1 2 3 4 5 6 7 { "fields": { "Select List Multiple Choices": [ {{#issue.Select List Multiple Choices 2}}{"value":"{{value}}"}{{^last}},{{/}}{{/}} ] } }

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 option below, as shown in the screenshot:

    • {{issue.Select List Multiple Choices 1}}

    • {{issue.Select List Multiple Choices 2}}

      select list multiple choice field using automation

Solution 4

  • 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):

    1 {"update": {"Select List Multiple Choices": [{{#issue.Select List Multiple Choices 2}}{"add": {"value":"{{value}}"}}{{^last}},{{/}}{{/}}]}}

Scenario 4 - Update the select field (multiple choices) with the content of a text field (single line)

Use Case 1

Let's assume that:

  • you configured a Single Line Text field that will be filled in with comma delimited values (for example "Option 1, Option 2, Option 3")

  • you are trying to populate the select field (multiple choices) based on the values that are listed in the Text Field

If you want to replace the content of the field with the values listed in the text field, you can configure the rule below:

Solution

  • 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):

    1 2 3 4 5 6 7 { "update": { "Select List Multiple Choices": [ {{#issue.Select List Multiple Choices 2}}{"add": {"value":"{{value}}"}}{{^last}},{{/}}{{/}} ] } }

Use Case 2

If you want to edit the field without overwriting its original content, you have 2 options:

Solution

  • 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):

    1 2 3 4 5 6 7 { "update": { "Select List Multiple Choices": [ {{#issue.Text Field Single Line.split(",")}}{"add": {"value":"{{.}}"}}{{^last}},{{/}}{{/}} ] } }

Updated on June 13, 2024

Still need help?

The Atlassian Community is here for you.