Getting an exception in 8.2 MVC site when requesting children of TreeNode

Kentico IT Support PPG asked on February 9, 2017 16:40

Creating a new 8.2 site from 8.1 code and running into an issue when trying to get children of a parent TreeNode.

[Exception: [TreeNode.Site]: Site is not specified or specified site does not exist.]
   CMS.DocumentEngine.TreeNode.get_Site() +125
   CMS.DocumentEngine.TreeNode.get_NodeSiteName() +8
   CMS.DocumentEngine.TreeNode.RegisterConnectedDocuments(DocumentRepository repository) +25
   CMS.DocumentEngine.TreeNode.get_ConnectedDocuments() +119
   CMS.DocumentEngine.TreeNode.get_Children() +13

Recent Answers


Brenden Kehren answered on February 9, 2017 17:19

What method are you using? Have you looked through the API documentation?

0 votesVote for this answer Mark as a Correct answer

Kentico IT Support PPG answered on February 9, 2017 19:00

This is being done with a query of a custom view:

// Add the main menu
DataQuery query = new DataQuery()
.From( "View_Custom_OLY_MenuItem" )
.Where( "Type", QueryOperator.Equals, "MainMenu" )
.OrderBy( "NodeOrder" );

viewModel.MainMenuItems = new InfoDataSet<TreeNode>( query.Execute() );

Let me ask another question that may help diagnose the problem ...

Is it possible that the GUIDs for DocumentNodes or any other node could change in a DB upgrade from 8.1 to 8.2?

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 10, 2017 02:10 (last edited on February 10, 2017 02:12)

you may try to add .OnSite("YourCodeSiteName") or .OnCurrentSite() to your query

 // Add the main menu
DataQuery query = new DataQuery()
.From( "View_Custom_OLY_MenuItem" )
.OnCurrentSite()
.Where( "Type", QueryOperator.Equals, "MainMenu" )
.OrderBy( "NodeOrder" );
0 votesVote for this answer Mark as a Correct answer

Kentico IT Support PPG answered on February 10, 2017 19:19

Peter,

Unfortunately, DataQuery does not support those extensions.

I am thinking that this isn't related to sites at all and that just happens to be the error that surfaces.

0 votesVote for this answer Mark as a Correct answer

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