How to separate a sublist in Yeeflow based on defined rules to generate multiple PDFs from Word documents or implement custom pagination

How can I classify content within a Yeeflow sublist by date and paginate the Word output based on these categories?

like this

I understand the requirements include two parts:

  1. Sort content by date: Group or categorize the items in the sublist according to the dates.
  2. Paginate output to Word: Export the content to a Word document based on the date-categorized results, with pagination.

Generating the Word document can be achieved using the Generate Document node in the workflow (Generate document action | Yeeflow Help Center), but the challenge lies in paginating based on actual data, as the number of pages is uncertain. Currently, the template can only bind a determined sublist variable to generate and output tables. Therefore, to fully meet the specified requirements, it remains necessary to custom develop a web API service to generate the corresponding document. The Sublist would be provided as parameters via the HTTP Request node.

Another idea is to use an AI assistant to help break down the data and generate the specified HTML source code. However, this still can’t meet the actual Word format requirements. Here are the specific steps, which I hope can provide you with some inspiration and reference:

Assume the form has the following controls:
Order No (Single line control)
Sublist (Sublist control)
Generate Button (Button control)
Generated (Richtext control)

Clicking the Generate button triggers an Action to generate a rich text result based on the data from Order No and Sublist into the Generated corresponding variable. Here is the design of the Action:

Configuration for the User message:

Assistant instructions:

Please split the user's input JSON array by the date attribute. The output should be in a fixed rich-text format, without any explanation or clarification. For example, the user's input: OrderNO:20250305A:[
{
"item": "A",
"itemcd": "A01",
"qty": 100,
"price": 1000,
"date": "2025/4/28"
},
{
"item": "A",
"itemcd": "A02",
"qty": 50,
"price": 600,
"date": "2025/4/28"
},
{
"item": "B",
"itemcd": "B01",
"qty": 20,
"price": 450,
"date": "2025/3/25"
},
{
"item": "C",
"itemcd": "C01",
"qty": 40,
"price": 680,
"date": "2025/4/28"
},
{
"item": "D",
"itemcd": "D01",
"qty": 50,
"price": 8000,
"date": "2025/5/12"
}
], your output is:
<p>PAGE1</p>
<p>ORDERNO: 20250305A-1	DATE:2025/4/28</p>
<table style="width: 85%; border-collapse: collapse; margin: 25px 0; font-size: 18px; text-align: left;">
<thead>
<tr>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">ITEM</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">ITEMCD</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">QTY</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">PRICE</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid #ddd; padding: 12px 15px;">A</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">A01</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">100</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">1000</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 12px 15px;">A</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">A02</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">50</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">600</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 12px 15px;">C</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">C01</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">40</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">680</td>
</tr>
</tbody>
</table>
<p style={break-after:page}>PAGE2</p>
<p>ORDERNO: 20250305A-2	DATE:2025/3/25</p>
<table style="width: 85%; border-collapse: collapse; margin: 25px 0; font-size: 18px; text-align: left;">
<thead>
<tr>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">ITEM</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">ITEMCD</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">QTY</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">PRICE</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid #ddd; padding: 12px 15px;">B</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">B01</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">20</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">450</td>
</tr>
</tbody>
</table>
<p style={break-after:page}>PAGE3</p>
<p>ORDERNO: 20250305A-3	DATE:2025/6/12</p>
<table style="width: 85%; border-collapse: collapse; margin: 25px 0; font-size: 18px; text-align: left;">
<thead>
<tr>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">ITEM</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">ITEMCD</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">QTY</th>
<th style="border: 1px solid #ddd; padding: 12px 15px; background-color: #f2f2f2;">PRICE</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid #ddd; padding: 12px 15px;">D</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">D01</rd>
<td style="border: 1px solid #ddd; padding: 12px 15px;">50</td>
<td style="border: 1px solid #ddd; padding: 12px 15px;">8000</td>
</tr>
</tbody>
</table>

The following are the actual execution results: