How to fetch information from master doctype to child table using the Fetch From field?


I am working on setting up Purchase Orders within ERPNext and would like to fetch the value entered in the ‘Cost Center’ field within the doctype to be automatically fetched by the ‘Cost Center’ field within the item table entries. I have tried to set-up the ‘Fetch From’ field but have not been able to find the proper Syntax. Any help would be appreciated.

My current attempt at the syntax needed for the ‘Fetch From’ field. this is entered within the ‘cost_center’ entry within the Item child table for Purchase Orders.


In Fetch From you can use the name of the link field followed by the field name in the linked doctype.
In your case cost_center.purchase_order

Hello, thank you for your reply.

However this does not seem to work. when i enter ‘cost_center.purchse_order’ i receive this error when trying to save a purchase order

I am continuing to work on this and have found that the “Set Warehouse” field does exactly what i want to be done with “Cost Center”, but I am uncertain how this “Set Warehouse” field works as there are no entries within the Fetch From Form

you need to do Client Script for that :slightly_smiling_face:


frappe.ui.form.on('Purchase Order', {
	onload(frm) {;
	    var items = frm.doc.items;
	    items.forEach(i =>{
	        i.cost_center = frm.doc.cost_center;


just tried this and it seems to work! thank you very much!