Get Value from Parent to Child Table

Hi Team,

Hope you are all are good, help requested regarding following 2 steps:

Step 1: Trying to fetch Price List field (i.e. selling_price_list) from Sales Order to custom field (i.e. price_list) created in Sales Order Item.

Script tried but no luck and it just hangs and doesn’t save the Sales Order: (I am not sure if there is something to do with Field Type)

frappe.ui.form.on("Sales Order", "validate", function(frm, cdt, cdn) {
var tbl = frm.doc.items || [];
var i = tbl.length;
var child = locals[cdt][cdn];
while (i--) {
    if(frm.doc.items[i].qty != 0) {
        frm.doc.items[i].price_list = selling_price_list;
        frm.refresh_field("items")
    }
}

});

Step 2: After populating Price List into Sales Order Item; custom amount field from Price List needs to be fetched and updated in every item’s custom amount field on the basis or Item Number and Price List, I guess but not sure how to do that.
Already requested help for step 2 in fact: https://discuss.frappe.io/t/fetch-value-of-custom-field-from-item-price-into-sales-order-item/26068

selling_price_list is also a doc field in the form, just like items. Try:

frm.doc.items[i].price_list = frm.doc.selling_price_list;

That price_list wasn’t in items it’s of Parent i.e. Sales Order and equated from Item Price.
But still I will try with index right now it is done after defining a variable.
Thanks a lot indeed.