Forums

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

Need Help for myGroovy Script

frank lohfeld December 6, 2021

Dear all,

I need help by develop a groovy Script.
I need a Script, that all from all Tickets in a Project "SWG" the Field Content from a custom multiline field attached to the system field description.
And I have no idea how can I do this. Please, can you help me?
The script should only run once a time.

Thanks in advanced

1 answer

1 accepted

1 vote
Answer accepted
PD Sheehan
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.
December 11, 2021

Let me see if I understand ... you wish to copy the text from a custom field and append it to the description of each issues in a project?

Something like this may work for you

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.event.type.EventDispatchOption

def searchService = ComponentAccessor.getComponent(SearchService)
def issueService = ComponentAccessor.issueService
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def jql = 'project=SWG'
def query = searchService.parseQuery(currentUser, jql).query

def cf = customFieldManager.getCustomFieldObjectsByName('name of your multiline cf')[0]

searchService.search(currentUser, query, PagerFilter.unlimitedFilter).results.each {
def issue = issueManager.getIssueObject(it.key)
def cfValue = issue.getCustomFieldValue(cf)
if(cfValue) {
def iip = issueService.newIssueInputParameters()
iip.description = issue.description + '\n\n' + cfValue
def updateValidationResult = issueService.validateUpdate(currentUser, issue.id, iip)
assert updateValidationResult.isValid()
issueService.update(currentUser, updateValidationResult, EventDispatchOption.DO_NOT_DISPATCH, false)
}
}
 
frank lohfeld January 6, 2022

thank you

Suggest an answer

Log in or Sign up to answer