Hi, I’m new around here
I’m trying to fetch data from a child table to another.
I have a DocType called “Cirugia”
(image in link)
and another DocType called “Solicitud de Remision”
(image in link)
each one of them have their own child table for products
DT Cirugia’s child table called: Almacen_cirugia
(image in link)
DT Solicitud de remision’s child table called: Almacen Solicitud de remision
(image in link)
Link for images: https://imgur.com/a/MBVBUYP (I couldnt upload images, dont know why )
I need to complete de form “Solicitud de Remision” and when I give Cirugia’s ID, it can fetch data from Cirugia DocType, but I need it to take data from the Cirugia’s child table to the Solicitud de remision’s child table (automaticlly)
How could I do this? I’ve tried these codes but they are not working for me
frappe.ui.form.on("Solicitud de Remision", {
refresh: function(frm) {
frm.add_fetch("id_de_la_cirugia", "fecha_cir", "fecha_de_cirugia");
frm.add_fetch("id_de_la_cirugia", "unidad_médica_cir", "unidad_medica");
//the code above works well for fetching data between DocTypes
//this line is one of the solutions that I tried but doesn't work
frm.add_fetch("id_de_la_cirugia", "consumos", "in_sol_rem");
}
});
//and tried this code that I took from github but didnt work for me
/*
frappe.ui.form.on("Solicitud de Remision", {
"id_de_la_cirugía": function(frm) {
frappe.model.with_doc("Cirugia", frm.doc.id_de_la_cirugia, function() {
var tabletransfer= frappe.model.get_doc("Cirugia", frm.doc.id_de_la_cirugia)
$.each(tabletransfer.Almacen_cirugia, function(index, row){
var d = frm.add_child("Almacen Solicitud de remision");
d.cod_pro_rem = row.codigo_de_producto;
d.cant_sol_rem = row.cant_pro_alm;
d.des_sol_rem = row.descripcion;
d.uni_sol_rem = row.precio;
d.tot_sol_rem = row.monto_total_de_la_remision;
frm.refresh_field("Almacen Solicitud de remision");
});
});
}
});*/
Any Ideas? !help