Skip to main content
aishwaryap610839
May 18, 2026
Question

Advanced Document Templating

  • May 18, 2026
  • 3 replies
  • 1 view

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! 

3 replies

shubhama926776
May 18, 2026

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(
    "",
    "",
    joinarray(
      a!forEach(
        items: local!labor,
        expression: concat(
          "",
          "",
          fv!item.name,
          "",
          "",
          fv!item.id,
          "",
          "",
          fv!item.role,
          "",
          ""
        )
      ),
      ""
    ),
    "",
    ""
  )
)

aishwaryap610839
May 18, 2026

How do we write the repeat block logic for per employee in WORD as you mentioned?

shubhama926776
May 19, 2026

Use this

[#list labor.employee as emp]

| Name | ID | Role |
| ${emp.name} | ${emp.id} | ${emp.role} |

[/#list]