Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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