Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Fetch data from Child Table to Parent Doctype Link field


I have a Parent Doctype called Forwarder with child Doctype Business Authorisation

I am trying to fetch Business Name from Business Authorisation child doctype to Transaction Doctype using a custom script. Instead, only the name appears in the dropdown.

This is my custom script

frappe.ui.form.on('Transaction', {
	refresh: function(frm) {
		frm.set_query("business", function(frm, cdt, cdn) {
			return {
				filters: [
					["parent", "=", frm.forwarder],
					["year", "in", [2020, 2021]]

There is no option to set search field in Business Authorisation child doctype

Please assist.


Try changing the child doctypes name-saving to field:business? Note that it will make the business field in the child table as unique

Thanks for the response.
The issue here is when you add a new row with the same business but a different year, the row doesn’t become unique anymore because you would have 2 rows with the same primary key and the system throws an error message.

try adding a fetch to the link field. i.e: field_business_name. replace field with the fieldname of your link field