Accessing Related Document Information from Macros

Carlos Batista asked on December 17, 2015 18:13

Hey guys,

So I have a Page Type that has multiple related documents. Im struggling right now trying to get information out of these related documents within the webpart transformation. For instance I have a staff member who has as related document a page type called Office. Office has fields like: City = Vancouver and Country = Canada.

Question 1 : When I try to access Office from the transformation through {% Office %} I get "Vancouver". But this is not enough. How can I output Office.City and Office.Country? For some reason that does not work.

Question 2: How would I go about looping through all available offices if they have more than one? How do I deal with related documents within a for or foreach loop?

Thanks in advance,

-C

Recent Answers


Joshua Adams answered on December 17, 2015 20:21

What if you add datasources for the pages that you want under neath, then use repeaters to access those items and set it up in the transformation like {%ClassName%}.Default or whatever they are named. You could to that or have separate datasources for the different types, I personally would use just the one that pulls in all to limit requests. The repeater can then handle the looping and all you need is a set of transformations that handles those different page types.

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on December 18, 2015 06:47

Hello,

you can loop through all the related pages like this in your transformation:

{%
foreach (doc IN Documents[NodeAliasPath].RelatedDocuments.All) {
Documents[doc.NodeAliasPath].GetValue("Country");
}
%}

However, I would recommend to change the way it's designed and instead of related pages I would take advantage of the content tree and make the hierarchy like:

- Country
-- City
--- Office

With this approach you have all the information available directly.

Best regards,
Jan Hermann

0 votesVote for this answer Mark as a Correct answer

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