Retrieving Related Items

I need to take a "Requirement Document" item_number, find all the related "Requirement Document Requirements" and their "Requirements".

Looking at the solution for Unit 8 in the v12 Developing Solutions guide I got a pretty good idea how to do this, but I really am just confused on why the (deprecated) "getRelationships" is used after "fetchRelationships" (which, the deprecation warning says to use instead).

Also, I don't need all the information from the related item, but the built-in function doesn't accept a list of properties for use in "select".

Anyway, why get then fetch?

And, what would I do to trim down the result set to only include properties of the child relationships?

Guide content:

result.fetchRelationships(“Design Request Document”);
Item relationships = result.getRelationships("Design Request Document”);

My function, which works, but has a warning causing my aforementioned confusion, and it uses the for loop that seems to do nothing. I found adding "related_id" to the list of properties in my first get actually returns the child "Requirement". So confused.

/*
TODO: Take in Requirement Document item_number after using hard-coded value for development.

RD-000001-0000

*/
Innovator innovator = this.getInnovator();
var reqDocNum = this.getProperty("item_number", "RD-000001-0000"); // TODO: Remove default value.
// Handle invalid input (with user facing error message)
if (String.IsNullOrEmpty(reqDocNum)) return innovator.newError("Valid Requirement Document Number required.");
//
var reqDoc = this.newItem("Requirement Document", "get");
reqDoc.setAttribute("select", "name");
reqDoc.setProperty("item_number", reqDocNum);
reqDoc = reqDoc.apply();
// Handle not reqDoc found (with user facing error message)
if (reqDoc.isEmpty()) return innovator.newError("No Requirement Document found for: " + reqDocNum);
// Fetch relationships of type Requirement Doc Requirement
reqDoc.fetchRelationships("Requirement Doc Requirement", "chapter,name,classification,is_released,state,major_rev,minor_rev,req_rm_text,related_id");
Item relationships = reqDoc.getRelationships("Requirement Doc Requirement", "item_number,name,classification,bl_release_state,state,major_rev,minor_rev,req_rm_text");
int count = relationships.getItemCount();
reqDoc.setProperty("RDR_COUNT", count.ToString());
for (int i = 0; i < count; i++) {
    Item reqDocReq = relationships.getItemByIndex(i);
    Item childRelationships = reqDocReq.getRelatedItem();
}
return reqDoc;

I tried to get things right, first with this AML...


     <AML>
  <Item type="Requirement Document" action="get" select="name">
  	<item_number>RD-000001-0000</item_number>
  	<Relationships>
  		<Item type="Requirement Doc Requirement" action="get" select="chapter,is_released,major_rev,minor_rev,related_id">
  				<related_id>
  					<Item type="Requirement" action="get" select="item_number,name,classification,bl_release_state,state,major_rev,minor_rev,req_rm_text">
  					</Item>
  				</related_id>
  		</Item>
  	</Relationships>
  </Item>
</AML>