Can't access custom field after getting TreeNode via DocumentHelper.GetDocuments()

Targutai Yesugei asked on August 8, 2017 08:41

Hello! I'm getting TreeNode of a custom page type and trying to get it's custom value, which is definetily declared in page type setting, but it returns null.

TreeNode isn't empty and seems got full info in it (including correct page type code name).

Here's my code:

var kenticoTreeNode = DocumentHelper.GetDocuments()
                .Where("NodeAlias", QueryOperator.Equals, "foo")
                .FirstObject;
kenticoTreeNode.GetValue("EktronContentID");

kenticoTreeNode can acquare TreeNodes with different page types, i tried on some and there was error at any page type.

Thanks in advance!

Correct Answer

Zach Perry answered on August 8, 2017 09:12

You need to include the classname of the document type: DocumentHelper.GetDocuments("classname")

Basically, that call generates a query to the database, without the classname there is no way to know which document type table to join to get the custom fields until the results come back, which would require multiple queries. This article may help.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Targutai Yesugei answered on August 8, 2017 09:40

Thank you, Zachary!

0 votesVote for this answer Mark as a Correct answer

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