I have created a listener that fires when an issuelink is created.
I need to get the value from my Source Issue's Epic Link field.
I have to be missing something simple, because I can't get it to work. My code as it stands is pasted below, and my log just says "epicLink: Epic Link"
Can someone tell me how to get the value of that field instead of what I assume is the field name?
Thanks in advance
---------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def linkMgr = ComponentAccessor.issueLinkManager
def cfManager = ComponentAccessor.customFieldManager
def issueLink = event.getIssueLink()
def sourceIssue = issueLink.getSourceObject()
def destinationIssue = issueLink.getDestinationObject()
log.warn ("issueLink: $issueLink")
log.warn ("sourceIssue: $sourceIssue")
log.warn ("destinationIssue: $destinationIssue")
// CHECK TO SEE IF THE SOURCE ISSUE ALREADY HAS AN EPIC LINK
def epicLinkField = cfManager.getCustomFieldObjectsByName("Epic Link") as List
def epicLink = epicLinkField.get(0)
log.warn ("epicLink: $epicLink")
I managed to find my own answer. The issue was that I only had the field itself, but not the value of the field on the issue itself.
the new working code to get the epic link value replaces what is under the comment:
// CHECK TO SEE IF THE SOURCE ISSUE ALREADY HAS AN EPIC LINK
// getCustomFieldObjectsByName() returns a collection. Appending [0] gets the first item in that collection, and since epic link can only have one value, we know this is correct
def epicLinkField = cfManager.getCustomFieldObjectsByName('Epic Link')[0]
// getCustomFieldValue is a method of Issue and needs a field object like we acquired in the above line
def epicLinkValue = sourceIssue.getCustomFieldValue(epicLinkField)
To anyone looking for things like this - the API documentation is here:
https://docs.atlassian.com/software/jira/docs/api/7.6.1/
It takes a bit to learn how to use if if you're not already familiar with these, but the answers are in there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This can't be for cloud, right? I can't do any of those imports
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.