How to make a field appear in drag&drop list in print editor

Hello again…

Im really sorry to ask this simple questions but i search and search and cannot find an answer and im running out of time.

In our project we use the “Supplier” form-type and it has a field called “supplier_id_card_no” among others like Supplier_name.

I can use all the variables for supplier but not this one. For example, i can get the supp-name with

{{ doc.supplier_name }} and the supp-address with {{ doc.supplier_address }}

But {{ doc.supplier_id_card_no}} fails. What could be the reason? I get an error that tells me that there is no such element called like that…

I saw also that this field doesnt appear in the drag&drop list in print form editor when i want to use this field on lets say in Purchase Invoice > #nameOfPrintformat. How can i make it appear there?

Im realy sorry to ask this questions but im on my own, diving into this really complex system… Thanks for any help or pointing me into the right direction…

Do you added doc.supplier_id_card_no in your document?

For purchase invoice, you need to add field supplier_id_card_no in Purchase Invoice.
So you can use it in your print format

Thanks for the quick answer. Sure, i added that line but i got an error coming up, that no objct could be found with this ID or name, not sure anymore.

Then i did what you said and added this variable/field also to the Purchase Invoice. But now it shows “nothing” as value, even the supplier that is set has something data in it.

You need to fetch supplier_id_card_no by cur_frm.add_fetch

Please go through this
https://kb.frappe.io/kb/customization/fetch-custom-field-value-from-master-to-all-related-transactions

If you need supplier_id_card_no for only printing, then I have one more solution
Try following code

{% set u = frappe.get_doc(“Supplier”, doc.supplier) %}
Supplier type: {{ u.supplier_type }}

Supplier Card No: {{ u.supplier_id_card_no }}

Thanks a lot for the info. I will try it tomorrow :slight_smile:

1 Like

I tried this now but it gives me the error “Supplier Supplier not found”… how can this be? There seems to be now typing error and of course there is a doc called Supplier.

ALso, in the link you provided, one step is to go to “Help > clear cache”. I dont see this in our system. Maybe it has been changed in a version update?

THen another question… i just saw that our doctype “Supplier” is for the module “Buying”. But the form i edit atm is in the section “Stocks”. Is this important? Or is this the reason i dont get the variables from that doctype…im getting more and more confused.

If i have one doctype set to a module, is this doctype only available to this module or anywhere in the site/pages?

The problem is that i take over the work in a already setup system with tons of doctypes and data. Seems many formfields are only set once in the master but never in the other places where i need them. Now its diffcult for me to see how all plays together. Really difficult… but i dont know how i can find the access here…

Edit: yeah… i tried everything now, i cannot get it to work…also this
https://kb.frappe.io/kb/print-formats/getting-information-from-another-document-in-print-format

The link from you, the other version only for print. Either i get error that Supplier isnt known or i get the value “none” instead of the real value in the datafield.

Lets do it step by step, please don’t confuse.

In v5 clear cache is changes to Reload
You can found this option ->

Ok, thanks. I did that. But it didnt help for my problem.

can you share your screen shot of purchase invoice and details if field which you want to print in print format?

ok i try again. last time i got error that new users cannot upload.

Supplier data for the Purchase Order supplier that is set for this order.

Empty values

This line gives me “empty” values. Not really empty but “none” is witten in the print doc.
{{ frappe.db.get_value("[Supplier]", “[supplier]”, "supplier_id_card_no ") }}

This line gives me the error that “Supplier Supplier” is unknown. The error comes alreay when i save the document in custom form edit mode. And the preview shows “page missing”. It doesnt even show the form with this line of code.

{% set sales_order_doc = frappe.get_doc(“Supplier”, supplier) %} {{ sales_order_doc.supplier_id_card_no }}

Same with this here, i get “none” for the variable.:
{{ doc.supplier_id_card_no }}

Funny enough it works with other variables like {{ doc.supplier_name }}

I can’t understand what you are doing, same post contain login for print format, custom script, custom fields.
Its better to Create new topic with you requirement.
Screen shot help to understand, so try to explain with screen shot

I just want to display the supplier tax id number and other data from an supplier-entry in various documents to print out. But i make a new post, since the usual question is answered already.

1 Like

Here is the link to the new topic: