ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Passing data from Child table to Print format using Jinja

customization
print_format

#1

I have a custom Doctype with Print format. I would like to show some data of a Child table in the Print format when this data is present in the Child table. I do not know what the syntax is to refer to Child tables.
How can I achieve this?


#2

Hii,
if your doctype has child table then you can try this:
For example if your child table name is items which has fields like item_code,item_name etc.
{%- for row in doc.items -%}
<tr>
<td>{{ row.item_code }}</td>
<td>{{ row.item_description }}</td>
<td>{{ row.item_name }}</td>
</tr>
{%- endfor -%}


#3

Thank you very much @lokesh, I am already able to show the data I want.


#4

Hello? Is there a way I can do this for the JS Print Format?


#5

yes kraysug. By using below code in your html file,you can do it for the js print format, but you have to render it from your js and pass parameters as data.
{% for(var i=0, l=data.length; i < l; i++) { %}
<tr>
<td> {%= data[i][__("contact")]%} </td>
<td> {%= data[i][__("name")]%} </td>
<td> {%= data[i][__("phone")]%} </td>
</tr>
{% } %}