How to use frappe.db.get_value for child table

I’m trying to use below query for child table:
item_name = frappe.db.get_value(“Sales Invoice Item”, “SINV-0239”, “item_name”)
When i’m trying to print item_name getting None.
Any changes required?


Prototype of function is like this:
get_value(table or doctype name, primary key value or name, and column of table)

You use like this:
frappe.db.get_value(“Sales Invoice Item”, “SINV-0239”, “item_name”)

Here “SINV-0239” is parent field is sales invoice item, you need name of sales invoice item, You can’t access directly like this.

You can you use like this:

doc = frappe.get_doc(“Sales Invoice”,“SINV-0239”)
doc.items return array of an item in given sales invoice number.

hi @bhavikpatel7023

i am trying like this
doc = frappe.db.get_doc(“Sales Invoice”,sales_invoice_id)
that is giving error
AttributeError: Database instance has no attribute ‘get_doc’

Sorry. There is frappe.get_doc() method.



1 Like

Hiiii @bhavikpatel7023

Yeah now its working fine Thanks for your query

Thanks & Regards
Mohammad Eliyas :grinning:


Your welcome.

Please mark as solution. so that will be helpful for other users in future.