Query related material doc

Hi, all,
i had created PO using material request…i want show the material request number and the material request name who has requested to that document which is fetch from material request form and want to show in PO format…

There must be some material request reference?


frappe.db.get_value("doctype", "docname", "fieldname")

to fetch value.

e.g. frappe.db.get_value("Material Request", "MREQ-00001", "required_fieldname")


i tried this… but still i got error…
here is my code…

dis got this error:-

frappe.db.get_value("Material Request", "Material Request", doc.name)

Incorrect way,

Check this,

frappe.db.get_value(Doctype, docname, required_field)    


frappe.db.get_value("Material Request", "MREQ-00001", "name")

In your case, I think material Request reference is in items table
Try this

 frappe.db.get_value("Material Request", doc.items[0].material_request,  "owner")

i want show full name of the requested person instead of email id…is it possible…?

frappe.db.get_value(“Material Request”, doc.items[0].material_request, “owner”)…its shown email of the requested person…i want to show full name of the requesting person…is it possible?