Getting value of Data Type and Form Control Pages

Jesper Allestam asked on August 14, 2018 18:04

Hi, I'm trying to load data from Pages fields from a TreeNode object in the code.

I have a couple of Pages fields on my document type, eight or nine, and is trying to get all the fields through "page.RelatedDocuments". I'm successfully retrieving a couple of the RelatedDocument lists but not all. Is there a better way fetching the related documents from a page?


foreach (var item in page.RelatedDocuments.DynamicNames) // <-- Only returning some of the lists
 RelationshipNameInfo relationshipNameObj =  

var relationShips = page.RelatedDocuments[item];
  var relationShipname = relationshipNameObj.RelationshipDisplayName;

  foreach (var page in relationShips)
    if (relationShipName.Contains(stringToMatch))
        var newPage = Helper.GetPageFromGuid(page.NodeGUID.ToString());
        var newObject = new NewObject
                Name = newPage.GetStringValue("PlayerName", ""),        

Correct Answer

Peter Mogilnitski answered on August 14, 2018 18:11

What is your Kentico version? Can you use documentHelper?

// Simulates a page GUID.
Guid nodeGuid = Guid.NewGuid();

// Retrieves smartphones that are in a specific relationship with a specific page.
DocumentQuery smartphones = DocumentHelper.GetDocuments("CMS.Smartphone")
                                .Path("/Products/", PathTypeEnum.Children)
                                .InRelationWith(nodeGuid, "IsRelatedTo");
1 votesVote for this answer Unmark Correct answer

Recent Answers

Jesper Allestam answered on August 14, 2018 18:33

Thanks for the reply, Peter,

Yes, I can use DocumentHelper, that query is returning the pages, but not per list, I have no idea what list each page is choosen in.

Or is there something i'm missing here?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.