Forums

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

Set value of custom field using Scriptrunner/Label

jkimrey
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 24, 2020

I have a custom field (Listbox allowing multiple values to be selected) and would like to set the initial value based on the value in a label.

So, for example, if the label contains "Test1" and "Test 2", I want to update the listbox value to "Value A", "Value B".

This would be a one time run to set the values on the listbox (without having to do so manually).

Thanks

2 answers

0 votes
Vasanta Kumaar
Contributor
October 8, 2020

Hi @Aditya Sastry ,

 

We are looking for the solution similar to above but we need to achieve when user edits the label field.

I tried with automation in JIRA plugin but the problem is if we update Label field with any values the custom field is getting updated. But I need to update for a particular label in label field.

Can you help me How to achieve this.

 

Thanks,

Vasantakumaar

0 votes
Aditya Sastry
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.
March 24, 2020

You can use a behavior or listener to do it

Aditya Sastry
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.
March 24, 2020

Is this needed to be done at a specific step? Project automation can also be used for this.

jkimrey
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 25, 2020

No, it's just a one time execution that needs to happen as we are switching from the label to the custom field - need to get existing label values into the custom field...

 

Thanks.

Aditya Sastry
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.
March 25, 2020

Below is how this can be done.

 

Create a step from any status to itself. Write a post function with JMWE plugin

Scripted (Groovy) Operation on Issue Post-function

def label =issue.get("labels")
issue.setFieldValue("Call-out",label )

or

issue.setFieldValue("Call-out",issue.get("labels"))

Replace "Call-out" with your field name.

After this has been set up, search for all such issues and bulk transition them. This will copy all the values in Label to the desired field. I have tried it in my system and it works.

Feel free to accept the answers, so others can see that the question was resolved if they have the same issue.  

Suggest an answer

Log in or Sign up to answer