2

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.

Rohan Dalvi
  • 1,215
  • 1
  • 16
  • 38

1 Answers1

2

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.

nickm
  • 5,936
  • 1
  • 13
  • 14
  • I get the following error when I point my browser to the end point after editing the `_ItemHierarchy` value to the appropriate ObjectID in both cases: {"_rallyAPIMajor":"2","_rallyAPIMinor":"0","Errors":["Server error with id d3bce2cf-5db5-4d39-b4d2-f9f80c43bfcf encountered"],"Warnings":[]} – Rohan Dalvi Mar 06 '14 at 18:39
  • Did you use valid OID for your workspace also, by replacing 1111 in the example? – nickm Mar 06 '14 at 19:04
  • Let's say that I pass a user story objectID to the looback query in the `_ItemHierarchy`, shouldn't I get the same story back in the result?. For example if I pass ObjectID = "1234" and TypeHierarchy is "hierarchicalrequirement" then will I get the same story(with ObjectID 1234) back in the result of the lookback call? – Rohan Dalvi Mar 06 '14 at 19:12
  • Yes, in my example, a top story 4444 is included in the response. – nickm Mar 06 '14 at 19:41
  • I am getting duplicate values in the response. For example: `{"Feature":16513799599,"Name":"EPIC: F194 This is a test story","FormattedID":"US5690"}` and again I get the same `{"Feature":16513799599,"Name":"EPIC: F194 This is a test story","FormattedID":"US5690"}` – Rohan Dalvi Mar 06 '14 at 19:45
  • Add "__At":"current" to get only the current snapshots.https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ItemHierarchy":4444,"_TypeHierarchy": "HierarchicalRequirement","__At":"current"}&fields=["Name","Feature"] – nickm Mar 06 '14 at 19:49