How to get document by current culture in a macro using documents collection

Mark Clark asked on December 18, 2018 21:12

I am trying to retrieve a document in a macro that uses the documents collection. How do I get the desired document in the current culture if all I have is the NodeGUID?

Example: {% ApplyTransformation(Documents.Where("NodeGUID='"+SomeVariable+"'"), "SomeTransformation") #%}

Looks like Documents only references the table CMS_Document and not the view that makes the NodeGUID column available which results in an error saying NodeGUID is not an available column; however, when I try to use WithAllData I get a conversion error on the NodeGUID value as described in this article

Recent Answers


Peter Mogilnitski answered on December 18, 2018 21:51 (last edited on December 10, 2019 02:31)

you are almost there: {% Documents.Where("NodeGUID = '" + SomeVariable + "' and documentCulture='" + CurrentDocument.DocumentCulture + "'").Transform("{#DocumentID#} - {#DocumentName#}")|(identity)GlobalAdministrator%} you can use Transform or ApplyTransformation(somename) (they are the same essentially).

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on December 19, 2018 03:45 (last edited on December 10, 2019 02:31)

First of all - post your comment below, please do not change the question. It would be better if you explain your scenario. May be it should be done in a different way. Where do you get this guid? {%documents. |(identity)GlobalAdministrator%} see if this one works

0 votesVote for this answer Mark as a Correct answer

Harper George answered on December 24, 2018 18:38

I think you got your solution.

0 votesVote for this answer Mark as a Correct answer

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