Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add multiple labels on an issue

Kamran786
Contributor
June 25, 2020

Suppose i have two custom fields A and B.

A has values abc

B has value xyz

While creating issue my Lables should be

Labels abc xyz

I tried to create Post Functions and used Copy from one field to another. It worked but what is happening suppose i created two post function one for A and another for B then its taking the last one and not concatenating.

So please suggest which post function should i use in order to get the correct values

3 answers

3 votes
Oliver Siebenmarck _Polymetis Apps_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2020

Hi @Kamran786 ,

As you have noticed, the Copy from post function will always overwrite what's already in the field and it cannot take input from two fields. You will need an app to achieve this. 

I would recommend Cloud Workflows, because I work for that vendor, but there are other options as well. If you go with our app, here's how to set up your post function: 

  1. Add the [CW] Update a field's value post function to your transition
  2. Configure it to update the labels field like this:

Add Labels.png

The app allows you to use different fields from your issue when setting the value. If your two custom fields had the ids 10045 and 10044, you would enter this into the value field:

 {{ c.issue.fields.customfield_10045 }}, {{ c.issue.fields.customfield_10044 }}

And that's it. Of course, there might already be labels set and those would be overwritten. If you want to keep your current labels and simply add the custom fields, use this as the value:

 {{ c.issue.fields.customfield_10045 }}, {{ c.issue.fields.customfield_10044 }}, {{ c.issue.fields.labels }}

Hope that helps,
  Oliver

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2020

You'll need to use a different post-function.

Copy field works by copying a field.  It takes the new data and overwrites the old content.

Labels (amongst others) is a field that holds a list of values (even if there's only one).  Your need here is to be adding to that list, not overwriting it with another value.  In the background, the code needs to

  • Read current list
  • Try to add new data
  • Post new list back into field

There are a couple of apps that do provide "add label" or "add to a mulit-value field" that will do it, but I'm not sure you have one that includes one.

0 votes
IMSSPL June 25, 2020

Did you got this? it is very to solved by using post function

IMSSPL June 25, 2020

Step 1: Read the Existing Label data in post function and keep variable

Step 2: Read the Field A and Field B data 

Step 3: Merge all these values and assign to label

 

 

This i have done - it is working...

Kamran786
Contributor
June 25, 2020

How did you do it via post function. Can you please let me know the steps. Because I have multiple custom fields and then I need to store all of them into Labels. The post function I tried is just overriding

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events