How to Access Child Table Data (Using Custom Script)

Guide

Sample code on how to manipulate data in a child table. This type of code falls under the parent form client side script page. And this particular example uses the trigger of a field value being changed then executes some code:

// access the Delivery Stop child table

frappe.ui.form.on("Delivery Stop", {

// there are different possible event triggers, but `field_name`--replacing this with the actual field name--means when value of a field in the child table is changed; need to include parameters form (frm), child doc type (cdt), and child doctype name (cdn)

  field_name:function(frm, cdt, cdn){

// declare a collections variable

  var u = locals[cdt][cdn];

// assign the value of `another_field` with `yet_another_field` when the changevalue event for `field_name` was triggered 

  u['another_field'] = u['yet_another_field'];

// refresh the field of the entire table, note that we are referring to the full table name as declared inside the parent form, in order to reflect the new value

  frm.refresh_field("delivery_stops");

    }

});

To load the entire form (including child table) into a variable:

let u = frappe.get_doc(cdt, cdn)

then access the array via u using dot notation or brackets.