frm.doc.onload is never going to work, because onload the Payment Entry has no idea where to get the details from.
You cannot fetch from doctype āSales Invoice Itemā because it is a Child Table, you should fetch from doctype āSales Invoiceā where the Child table is nested.
d = frm.add_child("Items") is wrong. You cannot have captial letters it should be d = frm.add_child("items") and you must have a field in Payment Entry which is called āitemsā and is of the type āTableā which in your case should have āSales Invoice Itemā in de options section.
$.each(tabletransfer.sales_invoice_item, function(index, row) should be $.each(tabletransfer.items, function(index, row) if you are going fetch from doctype āSales Invoiceā
Below I have edited all the points, now you need a field with type link to Sales Invoice in payment entry for your example I called the field āsales_invoiceā where you fetch all the child tables, if you want it to be automatic, then you need to write a python script for that, donāt think JS can handle that.
i want to make multiple delivery notes into 1 sales invoice. I have using Get Items From button to pick delivery notes available to make into 1 sales invoice.
I have added custom field in delivery notes doctype and i want to fetch that value into custom child table that i have created in sales invoice.