Question

I am using the lookback API, here's my code:

LookbackQuery query = this.lookback.newSnapshotQuery();
query.addFindClause("_TypeHierarchy", "PortfolioItem/Feature");
query.addFindClause("_ItemHierarchy", new BigInteger(workProductObjectID)); 
//here the workProductObjectID is the string representation of objectID of the user story.
//I am trying to look for the feature in that story's hierarchy.

query.requireFields("FormattedID","Name","ObjectID");
LookbackResult result = query.execute();

The totalResultCount returned is 0, but I can see that the story does have an assigned Feature. When I remove the '_ItemHierarchy' constraint, I get all features.

Was it helpful?

Solution

In the code you are limiting type hierarchy to PortfolioItem/Feature and at the same time want to get the item hierarchy that descends from a User Story, which is contradictory.

For this hierarchy:

Feature 3333
-Top Story 4444
--Child Story 5555
---Task 6666

An endpoint similar to the query in your code will return 0 results:

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ItemHierarchy":4444,"_TypeHierarchy": "PortfilioItem/Feature"}

To retrieve all stories that descend from Feature 3333 (includes stories 4444, 5555 but not task 6666), include this clause in your query:

{
    "_ItemHierarchy": 4444,
    "_TypeHierarchy": "HierarchicalRequirement"
}

which returns the same artifacts as this one:

{
    "_ItemHierarchy": 3333,
    "_TypeHierarchy": "HierarchicalRequirement"
}

If you want to fetch Feature, then make sure to include Feature it in the 'fields' statement. This is equivalent to the endpoint:

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ItemHierarchy":4444,"_TypeHierarchy": "HierarchicalRequirement"}&fields=["Name","Feature"]

It will return:

Results: [
{
Feature: 3333,
Name: "A Top Story One"
},
{
Feature: 3333,
Name: "A Story One"
}

Before writing the code you may test directly in the browser to see if your queries return what you expect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top