Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Need Help for myGroovy Script

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

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)
}
}
 

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you