Hi there,
I have a use case where I need to copy linked issue value to a custom field named "Initiative Link" on issue creation. I have added a Post function in the very first transition, the one between the start and first status.
With the below code, Inward and Outward links are displayed as empty arrays even though the field values are passed and because of this, the rest of the code is not being executed. Would be great if you could point out what is failing here.
Thanks a ton!
Poojaa
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.link.IssueLinkManager
def linkType = ["Is parent of"]
IssueLinkManager linkMgr = ComponentAccessor.getIssueLinkManager()
CustomField initiativeLink = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('Initiative Link');
log.warn "issue Summary: ${issue.getSummary()}"
log.warn "Inward links: ${linkMgr.getInwardLinks(issue.id)}"
log.warn "Outward links: ${linkMgr.getOutwardLinks(issue.id)}"
for (IssueLink link in linkMgr.getOutwardLinks(issue.id)) {
log.warn "Inside for: ${link.issueLinkType.inward}"
log.warn "${linkType.contains(link.issueLinkType.inward)}"
if (linkType.contains(link.issueLinkType.inward)) {
log.warn "inside if: ${link.destinationObject}"
issue.setCustomFieldValue(initiativeLink,link.destinationObject)
break
}
}
ComponentAccessor.getIssueManager().updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),issue,EventDispatchOption.ISSUE_UPDATED, false)
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.