Fetch a child table

Hello dears

i`v created a new doctype and successfully fetched the entire sales order details except sales order item table . but now i need to fetch the entire table which includes a custom field for technical description

any idea about how to do ??

1 Like

any idea about that ?

Check out this code:

hello @Sagar_Vora

acctally i mean something like that

What is your use case? If you need instant update across documents… wouldn’t you rather keep the additional fields as a part of the same document?

what i need is to copy the entire sales order item table from sales order doctype to my new doctype

SO, just to be clear, you want the functionality like “Get Items From”?

maybe or something like make which can make the sales order to invoice with all the details

In that case: see the code I linked above. Since you’re making your document from sales order, I gave as an example the function that executes in the backend when you make delivery note from sales order.

so will i need to repeat the with the new doctype ??

instead of delivery note ??

Yes, you need to write custom code in your custom app which will get executed when you click the button to get items. If you’re not comfortable with python you can get this done as paid development.

try this,

Customer: parent_table_name
items : child_table_name
x = frappe.get_doc(‘Customer’, ‘16gtrf3’).get(‘items’)

@Mahmoud_Ghoneem, I think you can also pull the items via Javascript using a series of frappe.client.get snippets but you’re going to need the name variable of the Document whose items you’re trying to fetch.

Can you also share the code you used to fetch the entire table from Sales Order so that we can see your approach to solving this one? Thanks! :slight_smile:

Hera

Is this server-side, what is 16gtrf3 in this case?

@Mahmoud_Ghoneem did you achieve this? Please share how.

not yet :frowning:

Please dont give up or withdraw it. Others will be working towards something similar. My being here is proof.

Here’s my script so far. Still trying to make it work. The fields are selectable in print preview but it isnt appearing at all. I suspect empty values.

//Including sales invoice items on the payment receipt.
frappe.ui.form.on("Payment Entry", onload, function(frm) {
    frappe.model.with_doc("Sales Invoice Item", frm.doc.onload, function() {
        var tabletransfer= frappe.model.get_doc("Sales Invoice Item", frm.doc.onload)
        $.each(qmtable.sales_invoice_items, function(index, row){
            d = frm.add_child("Items");
            d.item_code = row.item_code;
            d.item_name = row.item_name;
            d.description = row.description;
            d.uom = row.uom;
            d.stock_qty = row.stock_qty;
            d.item_name = row.item_name;
            d.rate = row.rate;
            d.amount = row.amount;

            frm.refresh_field("Items");
        });
    })
});
1 Like

replace qmtable with tabletransfer

Thanks, I also changed

sales_invoice_items

to

But still needs further troubleshooting.