Get parent treenode in a transformation

Guinea Piglet asked on May 9, 2020 14:24

Now i want to get the parent document name in a transformation. How can i do that?

Thanks.

Recent Answers


Peter Mogilnitski answered on May 9, 2020 14:34 (last edited on May 9, 2020 14:38)

{%CurrentDocument.Parent.DocumentName%} or <%# CurrentDocument.Parent.DocumentName %>

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on May 11, 2020 07:22

The <%# CurrentDocument.Parent.DocumentName %> may not always work and can cause an error. I would try using this syntax instead: <%= CMS.MacroEngine.MacroResolver.Resolve("{%CurrentDocument.Parent.DocumentName#%}") %> but it may end up with the same error.
For ASCX transformation I would rather recommend building a custom method and use the API to get the information you want.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on May 11, 2020 23:30 (last edited on May 11, 2020 23:55)

@Juraj is right. You need a full path: for ascx you need the <%= CMS.DocumentEngine.DocumentContext.CurrentDocument.Parent.DocumentName %>

0 votesVote for this answer Mark as a Correct answer

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