Macros return an empty string.

Konstantin Kompanets asked on April 28, 2020 14:54

Hi. I use Kentico 10. I need to get the NodeId of the current document in Page Type (Data source - SQL Query). But any macros from the CurrentDocument section return an empty string. What could be the problem? Other macros such as {% LocalizationContext.CurrentCulture.CultureCode #%} return data.

Image Text

Correct Answer

David te Kloese answered on April 28, 2020 17:13

Hi,

this is because CurrentDocument context isn't set. As you are about to create a new one anyway.

What you could use is {% EditedObject.NodeID #%} , note that this is NULL when creating a NEW page, as then even the Node isn't there yet.

2 votesVote for this answer Unmark Correct answer

Recent Answers


Konstantin Kompanets answered on April 28, 2020 17:34

Thank you, David! It works.

0 votesVote for this answer Mark as a Correct answer

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