Automation for Jira - Various methods to update a select field (multiple choices)

Still need help?

The Atlassian Community is here for you.

Ask the community

robotsnoindex

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

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

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": {
            "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. (info) 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": {
            "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}}

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": {
            "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}}

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": {
            "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:

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": {
            "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}}

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

    {
        "fields": {
            "Select List Multiple Choices": [
     			{{#issue.Text Field Single Line.split(",")}}{"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):

    {
        "update": {
            "Select List Multiple Choices": [
     			{{#issue.Text Field Single Line.split(",")}}{"add": {"value":"{{.}}"}}{{^last}},{{/}}{{/}}
            ]
        }
    }


Last modified on Jul 29, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.