Skip to main content
Version: 24.3

Determine Parent Epics with API

Imagine that you have a Portfolio Item/Epic hierarchy where you have a parent epic and a child epic, and that child has a child epic, and so on. Now, let's say you have been asked to provide a report that will show the stories in those epics and only the top most, or root level, Epic. So you need the parent of the parent and so on. How can you get that with the API?

You could always use Super And Up in the query to get all the Epics in reverse order for each story. Imagine your Story/Epic tree looks like this:

E-1001

E-1002

E-1003

E-1004

S-1001

Initially, you'd think about running a query like this:

"http://servername/versiononename/rest-1.v1/Data/Story?sel=Number,SuperAndUp.Name,SuperAndUp.Number&where=Scope.Name=" rel="freelink" title="http://servername/versiononename/rest-1.v1/Data/Story?sel=Number,SuperAndUp.Name,SuperAndUp.Number&where=Scope.Name=">http://servername/versiononename/res...re=Scope.Name="Project"

This would show you the stories and have columns for the SuperAndUp values and they would list in reversed order from the story, like this:

SuperAndUp.Number = E-1004, E-1003, E-1001

What if you ONLY wanted to grab the root level? Then you would need to query for SuperAndUp such that there isn't a Super - eg `SuperAndUp[-Super]`
or another way to express it is SuperAndUp such that Super is NULL - eg `SuperAndUp[Super='NULL']`
but the first form is more correct.

So the query is ~/rest-1.v1/Data/Story?sel=SuperAndUp[-Super]
which selects the topmost epic (if any) for each story,instead of selecting all epics up the Super hierarchy

 href="http://servername/versiononename/rest-1.v1/Data/Story?sel=Number,Name,Status.Name,Estimate,Team.Name,Timebox.Name,CreatedBy.Name,CreateDate,ClosedDate,SuperAndUp.Name,SuperAndUp.Number,Custom_System,SuperAndUp%5B-Super%5D&where=Scope.Name=" rel="freelink" title="http://servername/versiononename/rest-1.v1/Data/Story?sel=Number,Name,Status.Name,Estimate,Team.Name,Timebox.Name,CreatedBy.Name,CreateDate,ClosedDate,SuperAndUp.Name,SuperAndUp.Number,Custom_System,SuperAndUp[-Super]&where=Scope.Name=">http://servername/versiononename/res...re=Scope.Name="Project"

Learn the API