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

I would like to get data from Child table to Doctype like this :

Child Doctype : Purchase Receipt Item
Custom field : Batch Origin
Doctype : Batch
Custon field : Origin

Could someone help me?

Do you want to copy this field value when creating a new batch from the Purchase Receipt screen ?

Yes Exactly!

Have a look here:

The batch is automatically created when I submit the Purchase Receipt. I want the field “Origin” in the Batch DocType to have the same value as “Batch Origin” in Purchase Receipt DocType when it is automatically created.