ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

How to use frappe.db.get_value("[doctype]", "[name]", "fieldname")?



Hi everyone !

I’m new here and need some help from you guys. I currently develop some custom print formats for Payment Entry. I want to fetch some data from another document. I found that it is compulsory to use “frappe.db.get_value(”[doctype]", “[name]”, “fieldname”)" in order to get value from another document. I know [doctype] and [fieldname] part but for the [name] part, I have no idea at all. Can someone enlighten me on how to use this scripting :man_mechanic:?



“[name]” part is the filter that you want to fetch your desired fieldname upon, it is equivalent to the what came after where clause in the ordinary SQL query, for example “SELECT posting_date FROM tabPayment Entry WHERE name = ‘PE0001’”; so in the form of frappe.db.get_value it will be:
frappe.db.get_value(”Payment Entry", “PE0001”, “posting_date”)

hope that helps


Hi @ahmed-madi :slight_smile:

Thank you so much for your response ! I really appreciate it. However, I got one more question and really hope if you could help me on this.

I currently develop on custom print format for Payment Entry. As far as I know, Payment Entry somehow is connected with Sales Invoice. So let say, in the Payment Entry, I would like to have the party address which only can be retrieved from the Sales Invoice. How can I fetch the data ? Would you mind to explain on this?

Thank you in advance :grinning:


Sales Invoice reference is there inside the child table of the Payment Entry and there can be multiple Invoices. So, first you have to get the Sales Invoice from there. Then you can fetch the address from the sales invoice using frappe.db.get_value


Hi @nabinhait,

Would you mind to explain more on child table part ? Thank you :slight_smile:


I think you can get the invoice_no from the first row using doc.get("items")[0].reference_name