ERPNext Conference 2019* ERPNext.com Blog

Fetching child table to other parent docType error


#1

Good day devs! I created a child table name “Prescription” and used it inside “Patient Encounter” Doctype. I want to fetch the “Prescription” data in Sales Invoice Doctype. I tried it with this code and it always give me this error:

“You do not have enough permissions to access this resource. Please contact your manager to get access.”

here is my code (custom script on sales invoice) :

frappe.ui.form.on(“Sales Invoice”, {
patient: function(frm) {

	var patientName = frm.doc.patient; 
	
	//frappe.msgprint(patientName);
	
	frappe.call({					

		"method": "frappe.client.get",	
		"args": {
			"doctype": "Prescription",		
			"patient_name": patientName			
		},

		"callback": function(response) {
			var sinv = response.message; 
			frappe.msgprint (sinv.type_of_lens);	
		}
	});	
}

});

thank you so much in advance


#2

You need to grant permission to read (and possibly write/create) access to the Child Table's doctype for the account you try to access the record from.