I need to fill some field(Doctype A) to some field(Doctype B)

Hi,

I have a problem with custom script. I need in my Doctype A to fill 3 fields like (CustomerName, company, Description) but this information resides in Doctype B.

In Doctype A have

CustomerName
Company
Description

In Doctype B have

No opportunity
Other Field to Select: Customer or Lead.
So, if I select Customer. I need to apper only read the field (CustomerName, Company, and Description) or more information about this customer.

Can I help with the script correct or link for more examples.

Thank you

Look up add_fetch in the forums…

@Leonel_Gonzalez,

please check Problem fetching values to child table after update - #4 by makarand_b
or in
User Manual https://frappe.github.io/erpnext/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/custom-script-fetch-values-from-master

Thanks, Makarand

@makarand_b @Ben_Cornwell_Mott

Thanks for all.

I do the CustomScript with your information.

frappe.ui.form.on(“Oportunidad TIBA”,“refresh”, function(frm)
{
switch(frm.doc.oportunidad_desde)
{
case “Iniciativa”:
cur_frm.add_fetch(“iniciativa”, “giro”, “giro”);
cur_frm.add_fetch(“iniciativa”, “nomcliente”, “nomcliente”);
cur_frm.add_fetch(“iniciativa”, “descripcion”, “descripcion”);
cur_frm.add_fetch(“iniciativa”, “territorio”, “territorio”);
cur_frm.add_fetch(“iniciativa”, “nomcontacto”, “nomcontacto”);
cur_frm.add_fetch(“iniciativa”, “telcontacto”, “telcontacto”);
cur_frm.add_fetch(“iniciativa”, “dircontacto”, “dircontacto”);
cur_frm.add_fetch(“iniciativa”, “econtacto”, “econtacto”);
cur_frm.add_fetch(“iniciativa”, “secmercado”, “secmercado”);
cur_frm.add_fetch(“iniciativa”, “fechaidentificacion”, “fechaidentificacion”);

break;

case “Cliente”:
cur_frm.add_fetch(“cliente”, “giro”, “giro”);
cur_frm.add_fetch(“cliente”, “nomcliente”, “nomcliente”);
cur_frm.add_fetch(“cliente”, “descripcion”, “descripcion”);
cur_frm.add_fetch(“cliente”, “territorio”, “territorio”);
cur_frm.add_fetch(“cliente”, “nomcontacto”, “nomcontacto”);
cur_frm.add_fetch(“cliente”, “telcontacto”, “telcontacto”);
cur_frm.add_fetch(“cliente”, “dircontacto”, “dircontacto”);
cur_frm.add_fetch(“cliente”, “econtacto”, “econtacto”);
cur_frm.add_fetch(“cliente”, “secmercado”, “secmercado”);
cur_frm.add_fetch(“cliente”, “fechaidentificacion”, “fechaidentificacion”);
break;
}

var total = 0
total = flt(frm.doc.cmensual)/ (1 - flt(frm.doc.margen/100))
frm.doc.pmensual= total;

})

thanks. :slight_smile:

1 Like