In Rally, I was trying to query for a items in the tree that contained the word "Feature". I tried querying for (Parent.Parent.Parent.Parent.Parent.Name contains "Feature") etc by checking whether any of the parent names have the word "Feature" in them. My approach does not work. Is there a better way to do this? Thanks.
-
Are you querying Stories or Portfolio Items? Did you end up ORing a bunch of parent queries together? EX: ((Parent.Parent Contains "Feature") OR Parent.Parent.Parent Contains "Feature")) – Charles Ferentchak Jun 22 '12 at 15:08
-
I have not yet Or'd anything. However, I was trying to see any item in the hierarchy (that contains user stories, features etc) contained the keyword "feature" by chaining parents. I do not know what is the difference between stories and portfolio items. If you could provide me any resource or pointers to help me query portfolio (if that is what I need to query to accomplish what I am doing), that would be very much appreciated. Thanks. – user1133324 Jun 22 '12 at 15:42
-
Are you using the Rally Portfolio Manager to organize your stories? This rest URL will return some data if you are using the Portfolio Manager. https://rally1.rallydev.com/slm/webservice/x/portfolioitem.js – Charles Ferentchak Jun 22 '12 at 16:34
1 Answers
As Charles notes, it isn't possible to traverse a parent hierarchy via a single Rally Query. Ultimately, it will be possible to pull an entire hierarchy and filter on naming and other criteria using the (currently alpha) Lookback API and queries similar to that described in this article:
Lookback API: Find all leaf node stories under a known parent
Until then, you can traverse the hierarchy of parents using the AppSDK and recursive calls to the find() method of rallyDataSource. I've included a simple that does this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta name="Name" content="App Example: Parent Name Contains Story Hierarchy"/>
<title>Parent Name Contains Story Hierarchy</title>
<script type="text/javascript" src="/apps/1.27/sdk.js"></script>
<script>
var rallyDataSource;
function parentNameRecursionExample() {
var parentStoryHierarchy = function(results) {
var storyInfo = "";
var story = "";
var parentFormattedID = "";
for (i=0 ; i < results.stories.length ; i++) {
story = results.stories[i];
if (story.Parent != null) {
parentName = story.Parent.Name;
var testContains = "Parent";
if (parentName.indexOf(testContains) != -1) {
storyInfo += story.FormattedID +
', ' + story.Name +
', Parent:' + story.Parent.FormattedID +
': ' + story.Parent.Name + '<br>';
aDiv.innerHTML += storyInfo;
}
parentFormattedID = story.Parent.FormattedID;
var queryConfig = {
type : 'HierarchicalRequirement',
key : 'stories',
fetch: 'FormattedID,Name,Parent',
query: '(FormattedID = \"' + parentFormattedID + '\")'
};
rallyDataSource.findAll(queryConfig, parentStoryHierarchy);
} else {
storyInfo += story.FormattedID +
', ' + story.Name +
', Parent: No Parent';
aDiv.innerHTML += storyInfo;
}
}
};
var queryConfig = {
type : 'HierarchicalRequirement',
key : 'stories',
fetch: 'FormattedID,Name,Parent',//,
query: '(FormattedID = \"US130\")'
};
rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
rallyDataSource.findAll(queryConfig, parentStoryHierarchy);
}
rally.addOnLoad(parentNameRecursionExample);
</script>
</head>
<body>
<div id="aDiv"></div>
</body>
</html>
It traverses a Story Hierarchy that looks like this:
And filters for stories containing "Parent" in the Story Name, producing the following output:
Understood the sample is a rough cut and not very pretty, not as elegant or easy as a single query, but it illustrates how to traverse the tree and filter for the results you are looking for.

- 1
- 1