Created On:  03 July 2012

Problem:

How do you retrieve the Hierarchy number for a requirement using the CaliberRM SDK – C# .NET?

Resolution:

Attached is a Visual Studio project with C# code to retrieve the hierarchy number for a specified requirement ID.  The main section of the code to return the hierarchy number is shown below including comments:

//get project

Project myProject = mySession.Projects[3];

Console.WriteLine("Project: " + myProject.Name);

//get baseline - 0 = Current

Baseline myBaseline = myProject.Baselines[0];

Console.WriteLine("Baseline: " + myBaseline.Name);

//use RequirementTreeNode

RequirementTreeNode myBaseTreeNode, myReqTreeNode;

//get the root of the tree

myBaseTreeNode = (RequirementTreeNode)myBaseline.RequirementTree.Root;

//look through the tree for requirement id (in this example requirement id 292)

myReqTreeNode = (RequirementTreeNode)myBaseTreeNode.findRequirementNode(292);

//and return it's hierarchy number

string hierarchy = myReqTreeNode.HierarchyNumber;