Forums

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

Getting a Custom field value from an Inititave issue and prepopulate an Epic field of the same name

Sylvain Henrie
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!
May 8, 2019

In a project we have an Initiative issue that contains project information like financial code and such. I would like to have a script run that when any epic is created the value of this custom field financial code be prepopulated in these epic. I ma a beginner user with scriptrunner and have ni idea where to start.

 

Following code is what I came up with

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue


def customFieldManager = ComponentAccessor.getCustomFieldManager()

def issue = issue as MutableIssue

 

["Initiative"].each { cfname ->

def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == cfname}
log.error("cf : " + cf)
log.error("issue : " + issue)

def epicCf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Link'}

if (!cf || !epicCf) {return}

def epic = issue.getCustomFieldValue(epicCf) as Issue


if (!epic) {return}

def cfValue = cf.getValue(epic)
log.error("cfValue : " + cfValue)

issue.setCustomFieldValue(cf, cfValue)

}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events