Hi,
I would like to read custom field value from a linked EPIC. Once I am able to read the custom field value from EPIC/parent, I would like to set up this value to sub-task' custom field. I tried multiple forums but didn't help much.
I saw threads for reading custom field value, I am able to read custom field value from the issue I am in. However, a read from parent or epic is returning a null all times.
Thanks,
Smita
Could you provide your script?
Hi Alex,
I have this code which is reading value from linked EPIC and custom field value from its own custom field. However I am very new to scripting and I am not sure how can I make it read custom field value from a linked issue or EPIC. I tried few scripts and removed them when they didn't work.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.attachment.FileSystemAttachmentDirectoryAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.CustomFieldManager
String testlinkType = ["IT Parent"]
String testlinkStatus = ["child of"]
def output =""
IssueLinkManager linkMgr = ComponentAccessor.getIssueLinkManager()
CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager();
output+="issue key: " + issue.key +"<br></br>"
for(IssueLink link in linkMgr.getInwardLinks(issue.id))
{
output+="linked issue type: " + link.issueLinkType.name+"<br></br>"
output+="linked issue key: " + link.getSourceObject().getKey()+"<br></br>"
output+="linked issue status (name): " + link.getSourceObject().getStatus().getName()+"<br></br>"
output+="linked issue status (id): " + link.getSourceObject().getStatus().getId()+"<br></br>"
// output+=link
CustomField customField = cfManager.getCustomFieldObjectByName("Work Category");
def customFieldValue = customField.getValue(issue)
output+="My work category" + customFieldValue +"<br></br>"
//def customField = cfManager.getCustomFieldObject("Work Category")
// def childCfValue =link.getCustomFieldValue(customField)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your script would look like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.attachment.FileSystemAttachmentDirectoryAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.link.IssueLink
def linkTypeList = ["Epic-Story Link"]
IssueLinkManager linkMgr = ComponentAccessor.getIssueLinkManager()
CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager();
def customField = cfManager.getCustomFieldObjectByName("custom field name")
for(IssueLink link in linkMgr.getInwardLinks(issue.id))
{
if ( link.issueLinkType.name in linkTypeList) {
log.error(link.getSourceObject().getCustomFieldValue(customField))
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.