Copy four text field values to a new text field as four bullet points

 

Suppose I have four single line text fields:

Custom field 1
Custom field 2
Custom field 3
Custom field 4

after they are filled with text like text1, text2, text3,text4

There is a new multi line text field
Custom field 5

the custom field 5 should be populated with the four values from the custom fields as bullet points like

1.text1
2.text2
3.text3
4.text4

 

1 answer

1 vote
Alexey Matveev Community Champion Oct 28, 2017

Hello, 

First you need to define how your fields are updated.  If they are updated on transition or issue creation then you can develop a post-function.  If the fields are updated in the edit dialog then you should develop a listener. 

In any case your code would consist of the following parts:

1. You get 5 references to the field. Here is an example:

def cs1 = customFieldManager.getCustomFieldObjectByName("Custom field 1")

up to cs5

2. You concatenate values of the four custom fields:

def result = issue.getCustomFieldValue(cs1) + '\n' + issue.getCustomFieldValue(cs2) + '\n' + issue.getCustomFieldValue(cs3) + '\n' + issue.getCustomFieldValue(cs4) 

3. You set the result variable for multiline field:

def changeHolder = new DefaultIssueChangeHolder(); cs5.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cs5), result),changeHolder);

Thanks Alexey. Thankyou so much for the quick response.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

767 views 2 19
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you