Cascading /Nested Add Fetch

try this i write for user_id field you can change whatever field you want to fetch.

frappe.ui.form.on("Sales Order", "sales_person",function(frm,cdt, cdn) 
    	{
		
		if(frm.doc.sales_person)
		{
				frappe.call({
				"method": "frappe.client.get",
				args: {
					doctype: "Sales Person",
					name: frm.doc.sales_person
				},
				callback: function (data) {
					if(data.message.employee)
					{
				frappe.call({
				"method": "frappe.client.get",
				args: {
					doctype: "Employee",
					name:data.message.employee
				},
				callback: function (data) {
					frm.set_value("p_email", data.message.user_id);

				}
});
					
					}
				}

});
			

	
		
		}

	   
	});
3 Likes