Error in Creating Print Formats

Hi,
I was trying to create a ‘Print Format’ for Quotations. I created a new field in the customer form and I was trying to link this field to a particular cell in a table in the html. I used the syntax that was specified at the bottom of the page and got this error. I am unsure of what I should enter in the ‘Name’ parameter and thus left it blank.Could you please explain the difference between the ‘Name’ and ‘Fieldname’ parameters and help resolve this error.

Version : ERPNext: v4.5.2
Frappe Framework: v4.4.4
Shopping Cart: v0.4.0

My code :

<th align = "left">{{ frappe.db.get_value("Customer", "", vessel_name) }}</th>

Error:
Traceback (innermost last):
File “/home/erpnext/frappe-bench/apps/frappe/frappe/app.py”, line 49, in application
response = frappe.handler.handle()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py”, line 66, in handle
execute_cmd(cmd)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py”, line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/init.py”, line 531, in call
return fn(*args, **newargs)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 86, in get_html
html = template.render(args, filters={“len”: len})
File “/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 969, in render
return self.environment.handle_exception(exc_info, True)
File “/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "

customer name is blank (?)

you can see the full trace in bench terminal

Hi Mehta,
I tried filling in the customer name as “customer_name”. It is
still giving me the error. Could you please help me with the code. I want
to fetch a field named ‘vessel_name’ and populate it in the print format.

Thank you,
Akilesh

@akilesh_raj you need to fill in the customer name to fetch value from db. Check out eg.

  • Customer name is excellent
<th align = "left">{{ frappe.db.get_value("Customer", "excellent", "vessel_name") }}</th>
  • Customer name is ctech
<th align = "left">{{ frappe.db.get_value("Customer", "ctech", "vessel_name") }}</th>

if customer field name is customer is the doc you are developing print format for then following will work


<th align = "left">{{ frappe.db.get_value("Customer", doc.customer, "vessel_name") }}</th>

Hi Bhupesh,
I tried what you had suggested and I am still getting
the error. Could you please help.?

Thanks,
Akilesh

Can’t help unless you share your error trace and code.

Hi Mehta,

This is my code,

TO {{ frappe.db.get_value("Customer",doc.customer,"vessel_name") }} DATE {{ doc.transaction_date }}

This is the error message I am getting.

Traceback (innermost last):
File “/home/erpnext/frappe-bench/apps/frappe/frappe/app.py”, line
49, in application
response = frappe.handler.handle()
File “/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py”,
line 66, in handle
execute_cmd(cmd)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py”,
line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/init.py”,
line 531, in call
return fn(*args, **newargs)
File “/home/erpnext/frappe-bench/apps/frappe/frappe/templates/pages/print.py”,
line 86, in get_html
html = template.render(args, filters={“len”: len})
File “/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”,
line 969, in render
return self.environment.handle_exception(exc_info, True)
File “/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”,
line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "

Thanks,

Akilesh

Hey akilesh_raj,

This is what you are getting in browser. You need to login in to the server on which this is running and check out trace in logfile. Those are complete traces and will help to solve the issue you are facing.