Does anyone know if its possible to filter records that match a certain criteria when using <!-- {{#each function in PDF templates?
Announcement
Collapse
No announcement yet.
PDF {{#each Filtering Possible?
Collapse
X
-
You could embed"{{#if}} or {{lookup}} statements inside the {{#each}} loop or develop your own handlebars helper.
-
It certainly is; please read this:
I couldn't find where I original posted this but I just copy it and paste it from my template.
In the future this thread will be use for discussion; the Wiki hosted on Github will be used instead to post update; please see: https://github.com/o-data/EspoCRM-Learning-and-Design/wiki Part 2 of this post can be found here: https://forum.espocrm.com/forum/gene...5114#post55114 (https://forum.espocrm.com/forum/general/54706
Comment
-
Thank you espcrm the below from your post helped me. Here's my full code of my template this helps anyone else. I used this for our company budget tool.
<p style="text-align: center; "><b><span style="font-size: 18px;"><font color="#000000">{{name}}</font></span><br></b></p>
<font color="#000000" style=""><b>Expenses</b></font><br><table border="0.5pt" cellpadding="2" class="table table-bordered">
<tbody>
<tr>
<th width="8%" style="background-color: rgb(54,54,53); color: #ffffff;" align="left"><b>Line #</b></th>
<th width="35%" style="background-color: rgb(54,54,53); color: #ffffff;" align="left"><b>Budget Item</b></th>
<th width="8%" style="background-color: rgb(54,54,53); color: #ffffff;" align="left"><b>Type</b></th>
<th width="12%" style="background-color: rgb(54,54,53); color: #ffffff;" align="left"><b>$ Budgeted</b></th>
<th width="12%" style="text-align: right; background-color: rgb(54, 54, 53); color: rgb(255, 255, 255);" align="left"><b>$ Used</b></th>
<th width="12%" style="text-align: right; background-color: rgb(54, 54, 53); color: rgb(255, 255, 255);" align="left"><b>$ Available</b></th>
<th width="12%" style="text-align: right; background-color: rgb(54, 54, 53); color: rgb(255, 255, 255);" align="left"><b>% Used</b></th>
</tr>
<!-- {{#each budgetsItems}}{{#ifEqual budgetItemType "Expense"}} --> <tr>
<td>{{line}}</td>
<td>{{name}}</td>
<td>{{budgetItemType}}</td>
<td>${{totalBudgetedAmount}}</td>
<td align="right">${{amountUsed}}</td>
<td align="right">${{amountAvailable}}</td>
<td align="right">{{percentageUsed}}%</td>
</tr>
<!-- {{/ifEqual}}{{/each}} --> <tr>
<td><b style="background-color: rgb(255, 255, 255);"></b></td>
<td><br></td><td><b>Totals<br></b></td><td align="right"><b>${{totalAmountBudgeted}}<br></b></td><td align="right"><b>${{amountUsed}}</b></td><td align="right"><b>${{amountAvailable}}</b></td><td align="right"><b>{{percentageUsed}}%<br></b></td></tr></tbody>
</table>
<p><br></p>
<font color="#000000" style=""><b>Income</b></font><br><table border="0.5pt" cellpadding="2" class="table table-bordered">
<tbody>
<tr>
<th width="8%" style="background-color: rgb(54,54,53); color: #ffffff;" align="left"><b>Line #</b></th>
<th width="35%" style="background-color: rgb(54,54,53); color: #ffffff;" align="left"><b>Budget Item</b></th>
<th width="8%" style="background-color: rgb(54,54,53); color: #ffffff;" align="left"><b>Type</b></th>
<th width="12%" style="background-color: rgb(54,54,53); color: #ffffff;" align="left"><b>$ Budgeted</b></th>
<th width="12%" style="text-align: right; background-color: rgb(54, 54, 53); color: rgb(255, 255, 255);" align="left"><b>$ Used</b></th>
<th width="12%" style="text-align: right; background-color: rgb(54, 54, 53); color: rgb(255, 255, 255);" align="left"><b>$ Available</b></th>
<th width="12%" style="text-align: right; background-color: rgb(54, 54, 53); color: rgb(255, 255, 255);" align="left"><b>% Used</b></th>
</tr>
<!-- {{#each budgetsItems}}{{#ifEqual budgetItemType "Income"}} --> <tr>
<td>{{line}}</td>
<td>{{name}}</td>
<td>{{budgetItemType}}</td>
<td>${{totalBudgetedAmount}}</td>
<td align="right">${{amountUsed}}</td>
<td align="right">${{amountAvailable}}</td>
<td align="right">{{percentageUsed}}%</td>
</tr>
<!-- {{/ifEqual}}{{/each}} --> <tr>
<td><b style="background-color: rgb(255, 255, 255);"></b></td>
<td><br></td><td><b>Totals<br></b></td><td align="right"><b>${{totalAmountBudgeted}}<br></b></td><td align="right"><b>${{amountUsed}}</b></td><td align="right"><b>${{amountAvailable}}</b></td><td align="right"><b>{{percentageUsed}}%<br></b></td></tr></tbody>
</table>
<p><br></p>
-
I don't think you can with PDF Template for Sum Related Records. You certainly can do Formula to do that though. I recently made a post somewhere I call "Accounting" that make use of SumRelated formula.
---
PS: Pretty good looking designLast edited by esforim; 01-17-2023, 02:30 AM.
-
Comment