Email Alert (PO - save) error with custom field

Need to know whats wrong in the following Email Alert Template ( upon save)

Purchase Order {{ doc.name }} has been Created<hr>
<p>SUPPLIER: {{ doc.supplier_name }}<br>
PO Created by: {{ doc.owner }}<br>
PO Reference :
<span style="text-align: left; vertical-align: middle;">{{ _("#") }}{{ doc.name }}</span> {{ _("PO To:") }}: {{ doc.supplier_name }}<br>
{{ _("Address") }}: {{ doc.address_display }}</p>
<hr>
TITLE: {{ doc.title}}<br>

<table class="table table-condensed table-hover table-bordered" width="802">
<tbody><tr>
 
<th width="50">Sr</th>

<th width="100">Cat No</th>
<th width="400">Description</th>
<th class="text-right" width="100">Qty</th>
    <td align="right" style="border-style: none; border-width: medium;" width="187">
    <p dir="ltr">Pricelist Rate</p></td>
    <td align="right" style="border-style: none; border-width: medium;" width="187">
    Discount</td>
    <td align="right" style="border-style: none; border-width: medium;" width="187">Rate</td>
    <td align="right" style="border-style: none; border-width: medium;" width="176">
    Required For</td>
</tr><tr>
 
<td width="188">{{ row.idx }}</td>

<td width="188">{{ row.item_code }}</td>
<td width="187">{{ row.description }}</td>
<td width="187">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
    <td align="right" style="border-style: none; border-width: medium;" width="187">
 
{{
row.get_formatted("price_list_rate", doc) }}</td>
    <td align="right" style="border-style: none; border-width: medium;" width="187">
 
{{
row.get_formatted("discount_percentage", doc) }}</td>
    <td align="right" style="border-style: none; border-width: medium;" width="187">
 
{{
row.get_formatted("rate", doc) }}</td>
    <td align="right" style="border-style: none; border-width: medium;" width="176">
 
{{
row.get_formatted("required_for", doc) }}</td>
</tr></tbody>
</table>

{{ doc.terms}}<br>

I am getting the following error

Error while evaluating Email Alert a8e9311dabac3138acd01add6e7d6fd41230e4f723edd7d0f138602c. Please fix your template. Did not save

How do I fix this ??
Thanks in Advance

Mahesh

@malani_mahesh,

Can you share the error traceback, or console log ?

also, you will need to use the for loop to iterate through the PO items,
use {% for row in doc.items %} html code {% end %}

Thanks,
Makarand

Hi,

How do you get a error traceback and console log ? just a few hints please…

Also tried including this loop to iterate, but I got this error…

Line 50: Encountered unknown tag ‘end’. Jinja was looking for the
following tags: ‘endfor’ or ‘else’. The innermost block that needs to be
closed is ‘for’.Syntax error in template … Did not save

sorry, the syntax is {% for row in doc.items %} html code {% endfor %}

for console log, click f12 if you are using chrome, or right click on browser and click on inspect option.

Thanks,
Makarand

Hi, thanks, the correct syntax saved the alert template w/o any errors.

Also, heres the console log copy-pasted as per below.

The connection to wss://mahesheng.erpnext.com/socket.io/?EIO=3&transport=websocket&sid=VfLE2EDjU2OB6766AAnK was interrupted while the page was loading. desk.min.js:5490:15
unreachable code after return statement desk.min.js:70:12432
reflow: 0.44ms

Since the email alert is still not working, am still looking for the solution or a way I can fix this.

Regards,

another reminder since I posted this yesterday.
Any help available ?