Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I extract data from a multiselect custom field and populate each value as a label using JIRA

I have a custom field that displays a list of client codes.  This field is a multi-select field.  Using JIRA automation, I want to take each selected client code for that issue and insert that client code as a Label on the same issue.

1 answer

1 accepted

1 vote
Answer accepted

Hi! You can do this iterating through all of the multi-select values as a list and using advanced field editing to update them.

Here's what I tested putting into Additional fields, where my multi-select field is named "multi":

{
   "fields": {
      "labels": [
         {{#issue.multi}}"{{.}}"{{^last}},{{/}}{{/}}
      ]
   }
}

I'm not sure why I cannot include a screenshot of my rule, but I just got this to work.

Thanks Daryl, but I am not seeing the results on my end.  I copied this code and placed it in the Additional Fields.  The automation runs and says it is successful, but the Label field has not been updated with the Client Code(s) values.  Am I missing a step?

Should I update this code to reflect the custom field (Client codes) I want to use as the source?

{
   "fields": {
      "labels": [
         {{#issue.multi}}"{{.}}"{{^last}},{{/}}{{/}}
      ]
   }
}

Yes, "multi" needs to be replaced with the name of your custom field. If it has spaces, you would use:

         {{#issue."Your Custom Field Name"}}"{{.}}"{{^last}},{{/}}{{/}}

 And in some cases, that format doesn't always work either, so you might need to use:

         {{#issue.customfield_10034}}"{{.}}"{{^last}},{{/}}{{/}}

There's several ways to find the ID for the custom field: How to find custom field ids in jira 

Sorry Daryl.  I just reread your message and it works GREAT.  Thanks you!

Like Darryl Lee likes this

One last question Daryl.  If I want to populate the Label field from 3 different custom fields is that possible?  I want the values from Client Code(s), Service Team and Assigned Product to all be populated as individual labels on the issue.

I am assuming this in incorrect.

 

{
"fields": {
"labels": [
{{#issue.customfield_12100}}"{{.}}"{{^last}},{{/}}{{/}} , {{#issue.customfield_13731}}"{{.}}"{{^last}},{{/}}{{/}} , {{#issue.customfield_13732}}"{{.}}"{{^last}},{{/}}{{/}}
]
}
}

Hi Doug - yes, that looks right to me. By the way, I always test my rules by using a Manual Trigger that is only visible to me (administrator or site-admin group, for instance.)

https://support.atlassian.com/jira-software-cloud/docs/manually-run-a-rule-against-an-issue/

Then I can create a single test issue, add all the values I want to the custom fields, and then manually run it. If needed, I can clear the Labels on that issue and then try it again.

OH, I should note that using that code will replace any other labels. If you wanted to update, you would need to use something like:

{
    "update": {
        "labels": [
{{#issue.customfield_12100}} { "add" : "{{.}}" } {{^last}},{{/}}{{/}} ] } }

But I'm not sure Automation will do the right thing with those extra { } around the "add" clauses.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Automation

Announcing the Jira automation template library!

Hi all,  After many months of work, I am delighted to announce the launch of the Jira Automation Template Library!  The Template Library is a new website dedicated to all things Jira au...

703 views 12 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you