I want to populate one child tablefrom another child table

frappe.ui.form.on('Sales Order', {
  item_code: function(frm, cdt, cdn) {
	var row = locals[cdt][cdn];
	if (row.item_code) {
	   
		frappe.model.with_doc("Items", row.item_code, function() {
			var doc = frappe.model.get_doc("Items", row.item_code);
			$.each(doc.items || [], function(i, r) {				
			if(r.item_name == frm.doc.items) {				
				i = frm.add_child("custom_item_serial");
				i.item_series = r.item_name;
	         }	
			 	
			});
			
			cur_frm.refresh_field("custom_item_serial");  
		});		
		 
       }
   }
});


I want to get the item code from the upper table to the item series when i select each irtem the item codes hould populate here