RelativeUrl is null on all DocumentHelper TreeNodes

James Mosquito asked on March 29, 2021 19:55

Hi I am using the DocumentHelper to get various TreeNodes for different page types and narrowing the columns that are resolved:

var classNames = new[] { "class", "names" };
var columns = new[] {
    "NodeID",
    "NodeParentID",
    "NodeAliasPath",
    "NodeLevel",
    "DocumentID",
    "DocumentName",
    "DocumentUrlPath"
};

var childNodes = DocumentHelper
    .GetDocuments()
    .Types(classNames)
    .Path(path, PathTypeEnum.Children)
    .NestingLevel(maxDepth)
    .Columns(columns)
    .LatestVersion(_latestVersionEnabled)
    .Published(!_latestVersionEnabled)
    .OnSite(SiteContext.CurrentSiteName)
    .Culture(_cultureName)
    .CombineWithDefaultCulture()
    .OrderByAscending("NodeOrder")
    .ToArray();

The DocumentUrlPath and RelativeUrl are both null on all of the items returned. Are there some other columns I need to include in the query? (I tried adding RelativeURL which throws an exception due to the column not existing?)

Essentially I need to retrieve the live url for each document which does not always match the nodealiaspath field etc.

Thanks Jay

Recent Answers


Juraj Ondrus answered on March 30, 2021 06:43

What version and hotfix are you using? Also, what is the development model? I am asking since the DocumentURLPath was used in portal engine only and I would say the same applies for RelativeURL - when using MVC/Core, you have the routing in place instead.

0 votesVote for this answer Mark as a Correct answer

James Mosquito answered on March 30, 2021 10:52

Hi Juraj,

I am using Kentico 12 SP.

If I omit the columns constraint from the example in my OP then the RelativeUrl value is populated for all of the TreeNode items. I'm assuming that the relative url must depend upon some other columns to compile it's value.

Thanks, James

0 votesVote for this answer Mark as a Correct answer

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