overly-complicated macro text/xml transformation

kyle shapiro asked on September 24, 2015 23:30

So I have formed a solution for the problem I was having, but I have a strong feeling that it is probably NOT the best way of going about this. So I have a employee folder at the root of my site content tree, and it has all the employees for the whole company in it. Then under specific state and location pages, there is a reference for that employee in every location where the employee belongs. Locations can have many employees, employees can have many locations. On the original employee page under the employees folder, I want to have a repeater that repeats fields from all of it's linked page's parents. I am able to do this with the following macro:

stringBuilder = "";
for (i = 1; i < CurrentDocument.Links.Count; i++) {
  stringBuilder += "Linked Document's Parent's Name: ";
  stringBuilder += CurrentDocument.Links.GetItem(i).Parent.DocumentName;
  stringBuilder += "<br><br>";
return stringBuilder;

Placing this into a transformation and applying that transformation to a repeater on my page gives the desired result:

Linked Document's Parent's Name: ParentPageA

Linked Document's Parent's Name: ParentPageB

Although this works, I can't help but feel that it's extremely error prone, and that there should be a better way. Any suggestions?

Correct Answer

Maarten van den Hooven answered on September 24, 2015 23:43

Hi Kyle, you don't need the macro in the transformation, you can use the Relationships properties in the repeater webpart.

More detail are described here : Displaying related documents

Hopefully this will help you, and if not please let us known.

If this answer helped you, please vote for my answer :-)

1 votesVote for this answer Unmark Correct answer

Recent Answers

Brenden Kehren answered on September 25, 2015 00:13

Kyle, I'm working on a blog post with code samples on this right now. I hope to have it published by tomorrow. So stay tuned...

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 25, 2015 19:05

Kyle, here is my post on related documents in transformations, take a look. I'd recommend using related documents vs. linked documents. No need to have that extra overhead if you don't need it.

0 votesVote for this answer Mark as a Correct answer

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