Can we Fetch multiple rows of a field in generate template plugin so that they can be seen in mail , as when i tried to introduce them with input field option given in the plugin it only fetched one row . Can it be done , if yes how ?
Thank you
Yes, this is definitely possible!
The reason Generate Template only fetched one row in your initial attempt is because the Generate Template step processes incoming stream data on a row-by-row basis. For each individual row passing through the pipeline, it generates a single output string. When passed to an email step, it only sees one row at a time.
To display multiple rows of data inside a single email body, you must aggregate the rows into a single field/string before passing the stream into the Generate Template step.
Here are the two standard ways to achieve this in Process Studio:
Method 1: Using the “Group by” Step (Quick Concatenation)
If you want to merge multiple row values into a simple list or line-separated text:
- Insert “Group by” Step: Place a Group by step directly before your
Generate Templatestep. - Set Grouping:
- Group fields table: Leave this completely empty if you want to combine all rows in the dataset into a single record.
- Configure Aggregation:
- Under Aggregates, select your input field in the Subject column.
- Set Type to Concatenate strings separated by ….
- In the Value / Separator column, enter
<br>(for HTML line breaks) or a comma/newline.
- Insert into Generate Template:
- Double-click your newly aggregated field from the Input Fields list in the Generate Template step to add its placeholder (e.g.,
?{aggregated_field}) into your template string.
- Double-click your newly aggregated field from the Input Fields list in the Generate Template step to add its placeholder (e.g.,
Method 2: Building an HTML Table (Best for Email Reports)
If you want the multiple rows rendered as a formatted HTML table inside your email:
- Format Rows in JavaScript (“Modified Java Script Value” Step): Add a JavaScript step before aggregation to format each incoming row into HTML table row tags:
var row_html = "<tr><td>" + item_name + "</td><td>" + item_status + "</td></tr>";
- Combine Rows (“Group by” Step): Add a Group by step after JavaScript:
- Leave Group fields empty.
- Under Aggregates, set Subject to
row_htmland Type to Concatenate strings separated by …. - Set the aggregated result field name to
table_body.
- Embed in “Generate Template”: In your Generate Template step, construct the surrounding HTML table structure and double-click
table_bodyto insert the placeholder