Forums

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

Setting Custom Fields To The Same Value On Different Issues

Will C
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.
August 31, 2018

Hi guys,

I am trying to copy a custom field value from one issue to another linked issue.I can get find the linked issue object of the kind I want and can retrieve the value of the custom field from the first issue however I am struggling to set it on the linked issue. I understand I need to give it an "option" as its a select list, I've tried the way I set a checkbox but this was unsuccessful. would you be able to review my code and give me some pointed on what I need

def issueManager = ComponentAccessor.getIssueManager()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def projectMgr = ComponentAccessor.getProjectManager()

CustomFieldManager fieldmgr = ComponentAccessor.getCustomFieldManager();
IssueManager issueMgr = ComponentAccessor.getIssueManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager();;
def issue = issueMgr.getIssueObject("issuekey") 

def linkedIssue;
issueLinkManager.getInwardLinks(issue.id).each {issueLink ->
if (issueLink.issueLinkType.name == "link name") { 
linkedIssue = issueLink.getSourceObject()

}
}
//return linkedIssue
def cfname = customFieldManager.getCustomFieldObjectByName("customfieldname")
def cfragval = issue.getCustomFieldValue(cfname)
linkedIssue.setCustomFieldValue(cfname, cfragval)

 

1 answer

0 votes
Will C
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.
August 31, 2018

Sorry should have said that I am using the same custom field on both issues, just want to transfer the value accross from one to the other linked issue.

Suggest an answer

Log in or Sign up to answer