Forums

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

Scriptrunner script to Append Description with contents of custom text field

Stephen Letch
Contributor
January 14, 2019

Hi

 

I've Googled all over and the closest I've gotten is

 

package UpdateIssue
 
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
 
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
 
issue.setDescription(customFieldManager.getCustomFieldObjectByName("Affected Users").getValue(issue).toString() + "/" + customFieldManager.getCustomFieldObjectByName("Implementation Details").getValue(issue).toString())

 

However this replaces the Description text instead of adding to it.

I'm trying to add some custom field contents to the Description on a post function, so that when the Jira Service Desk approver email is sent to an approver, it includes all of the details in the Change Request.

 

I essentially want:

-----------------

Original Text in the description

 

Name of Custom field 1:

Contents of custom field 1

 

Name of custom field 2:

Contents of custom field 2

------------------

and so on.

1 answer

0 votes
Tarun Sapra
Community Champion
January 14, 2019

Hello @Stephen Letch

Why don't you first save the current description in a variable using

def description = issue.description

and then in issue.setDescription you can append the custom field values to the above variable "description" which is holding the current value of description.

Stephen Letch
Contributor
January 14, 2019

Can you provide an example? I'm not a coder so am having to pull examples from where I can to make this work.

 

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events