ERPNext Conference 2019* ERPNext.com Blog

Fetching data from a table to another

customization
erpnext

#1

I want to fetch a field ‘description’ from Sales invoice table in Subscription doctype and want to display it in the table Sales invoice item in Sales invoice.
Can some please help me with this?
Thanks in Advance


#2
frappe.call({
			method: 'contract.contract.doctype.contract_award.contract_award.methodname',
			freeze: true,
			args: {
					"parent": parentname
					
				},
			callback: function(r) {
			here you can get your description  after that you can set value like that

			
frappe.client.set_value(doctype, docname, fieldname, r.message.value)
		}
        })
	
}
});

other ways are

You can get value from other doctypes using

value = frappe.db.get_value(doctype, docname, fieldname)
and set value in single doctype

frappe.client.set_value(doctype, docname, fieldname, value)
For single doctype, doctype and docname are same