Fatch Data from custom doctype to table

I have created custom doctype called drawing details. Its marked as Child table. It contains a field called Party name which is link to customers doctype. Once customer can have multiple drawing details.

Now i have created custom field called DrawingNumber which is a dropdown. How can i achieve that when i click on this dropdown it should fetch Drawing numbers associated with that customer and once selected it should fetch all related field data to the sales order doctype as table.

Reference: Fetch Child table form one doctype to other doctype - #6 by NCP

Hi Thank you for this video this works for me in partially and I did take your video as guidance to make it work but I also have another situation where on my sales order I have child table called “Color Details” I want to copy entire table from sales order to work order can you suggest me on that.
Here is the screenshot of the table from my Sales Order

Again check the full video, because we fetch the sales invoice doctype data to invoice doctype with whole table details.

My bad i think i had error in my script. The issue is when i generate the workorder its not auto populating the table i have to reselect the sales order and then it will populate the script i want this data to be fetched automatic as i create workorder.

frappe.ui.form.on('Work Order', {
    sales_order: function(frm) {
        if (frm.doc.sales_order) {
            frappe.call({
                method: 'frappe.client.get',
                args: {
                    doctype: 'Sales Order',
                    filters: {
                        name: frm.doc.sales_order
                    }
                },
                callback: function(r) {
                    if (r.message) {
                        // Clear existing custom color details table rows
                        frm.clear_table('custom_color_details');

                        // Iterate through the fetched data from custom_color_details and populate the table
                        r.message.custom_color_details.forEach(function(item) {
                            let child = frm.add_child('custom_color_details');
                            child.color_name = item.color_name;
                            child.panton_code = item.panton_code;
                            child.cylinder_no = item.cylinder_no;
                            // Add other child table fields as needed
                        });
                        
                        // Refresh the child table to show updated data
                        frm.refresh_field('custom_color_details');
                    }
                }
            });
        } else {
            // Clear the custom color details if no sales order is selected
            frm.clear_table('custom_color_details');
            frm.refresh_field('custom_color_details');
        }
    }
});

Without selecting sales order, how can get the data. If you want to explore the look like “Get Item From” functionality, then please check the video.

Thank you dear I just added on load event into the script to make it work. Really appreciate your help again :slight_smile: