How to use value both from master and child table

I have a code here to calculate each item lead time based on the item delivery date and the transaction date. This script I wrote for the child table form in Sales Order Item, and it is not working. how to fetch the transaction date from Sales Order master? I input the result into duration field.

frappe.ui.form.on('Sales Order Item', "refresh", function(frm, cdt, cdn){
    var d = locals[cdt][cdn];   
    frm.set_value("custom_item_lead_time", frappe.datetime.get_day_diff( d.delivery_date , d.transaction_date * 86400));
    refresh_field("custom_item_lead_time");
});

Jevon

Hi @jevht
Please try this code. I hope you will help

frappe.ui.form.on('Sales Order Item', {
	item_code:function(frm,cdt,cdn) {
	    cal_auto(frm,cdt,cdn)
	},
	qty:function(frm,cdt,cdn){
	    cal_auto(frm,cdt,cdn)
	    
	}
});
function cal_auto(frm,cdt,cdn){
    frm.set_value("custom_item_lead_time", frappe.datetime.get_day_diff( d.delivery_date , d.transaction_date * 86400));
}

Thank You!

Hi thankyou for replying,

the script doesn’t work. The lead time is not showing on each item.

Jevon