Forums

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

Getting Epic Link from Issue/Story

integmas April 28, 2020

Hello all, I am developing a event listener plugin using the example in the docs.

I have a User story which is in a Epic and in my listener whenever the User story is updated i want to perform some action on the story for which i also need the ID of the Epic.

From the UI i can see the Story is linked to Epic (under "Epic Link"), but in the the issue object, i get in the listener i cant seem to be able to see the property, i have seem examples where people have tried to use customfields to get the Epic info. When i debug, i see that the issue has no customfields.

Is there any other way to get the Epic ID from User Story.

 

Thanks in Advance

2 answers

1 accepted

0 votes
Answer accepted
integmas April 28, 2020

I was able to solve my problem by doing the following

 

// this does not work, returns null
// CustomField field = customFieldManager.getCustomFieldObject("Epic Link");
// i have seen examples of this, but doesnt work
// CustomField field2 = customFieldManager.getCustomFieldObject("customfield_10101");


// What worked was
List<CustomField> fields = customFieldManager.getCustomFieldObjects(issue);

CustomField epicLinkField = null;
for (CustomField field : fields) {
if ("Epic Link".equals(field.getFieldName())) epicLinkField = field;
}

Issue epicLink = null;
if (epicLinkField != null) {
// we get the Epic issue object
epicLink = (Issue) issue.getCustomFieldValue(epicLinkField);
}
0 votes
Elad Ben-Noam
Contributor
April 28, 2020

@integmas - Epic link change doesn't have a webhook you can use.

So changing the epic link in the UI doesn't trigger anything.

You can create a schedule automation to run every X mins/hours/days (depending on what you're trying to get) and copy the epic link to a new custom field (text type). Then, when the value of that custom field changes you'll get a webhook notification to your listener.

integmas April 28, 2020

Thanks for the reply.

I want to get the Epic name from issue, i have created a EventListener in my plugin using the annotation "@EventListener".

I am able to catch the issue in my listener but i cant see a way to get "Epic" from issue, without running any queries.  

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

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 Now
AUG Leaders

Atlassian Community Events