How can I iterate the whole table for the requirement? How should the syntax be placed for Advanced Document templating plugin. I understand the code how we can loop through the rows in a grid but how can we loop the grid itself? eg: If I have 5 employees under Labor grid I want 5 different grids dynamically created based on syntax!
Discussion posts and replies are publicly visible
You cannot loop the grid itself; instead, build XML with repeated <employee> nodes using a!forEach and concat, then wrap the entire table inside a repeat block for each employee in your DOCX template so 5 employees produce 5 separate grids.
See this example
a!localVariables( local!labor: { a!map(name: "John", id: "101", role: "Developer"), a!map(name: "Mary", id: "102", role: "Tester"), a!map( name: "Sam", id: "103", role: "Business Analyst" ) }, concat( "<project>", "<labor>", joinarray( a!forEach( items: local!labor, expression: concat( "<employee>", "<name>", fv!item.name, "</name>", "<id>", fv!item.id, "</id>", "<role>", fv!item.role, "</role>", "</employee>" ) ), "" ), "</labor>", "</project>" ) )