It's basically the same code. The fieldName
parameter for the GetRelatedDocuments
method is used to retrieve the relationship name code name. Using that code name, you can find the related documents for a NodeGUID with the InRelationWith
parameterized method of the MultiDocumentQuery.
Here's the code for the TreeNode.GetRelatedDocuments
method:
protected MultiDocumentQuery GetRelatedDocuments(string fieldName)
{
FormFieldInfo formField = FormHelper.GetFormInfo(this.NodeClassName, false, true, false)
.GetFormField(fieldName);
if (formField == null)
return new MultiDocumentQuery().NoResults();
string relationshipNameCodeName = RelationshipNameInfoProvider
.GetAdHocRelationshipNameCodeName(this.NodeClassName, (IField) formField);
RelationshipNameInfo relationshipNameInfo = RelationshipNameInfoProvider
.GetRelationshipNameInfo(relationshipNameCodeName);
return RelationshipInfoProvider.ApplyRelationshipOrderData(
DocumentHelper.GetDocuments()
.Culture(this.DocumentCulture)
.CombineWithDefaultCulture(
this.TreeProvider.GetCombineWithDefaultCulture(this.Site.SiteName))
.Published(!this.IsLastVersion)
.PublishedVersion(!this.IsLastVersion)
.WithCoupledColumns(true)
.InRelationWith(this.NodeGUID, relationshipNameCodeName, RelationshipSideEnum.Left),
this.NodeID,
relationshipNameInfo.RelationshipNameId);
}
Hope that answers your question.