var ov = ZDK.Page.getField("Orden_de_venta");
if (ov) {
var orden = ov.getValue();
if (orden && orden.id) {
var ovId = orden.id;
var orden = ZDK.Apps.CRM.Sales_Orders.fetchById(ovId);
var regpresupuesto = ZDK.Apps.CRM.Quotes.fetchById(orden.Quote_Name_Lookup_Id);
if (regpresupuesto && regpresupuesto.id) {
var direnvio = ZDK.Page.getField("envio_direccion");
direnvio.setValue(regpresupuesto.Direcci_n_de_env_o); // this is working
var contactoenvio = ZDK.Page.getField("envio_contacto");
contactoenvio.setValue(regpresupuesto.Contact_Name); //this is NOT working
var contactoOV = ZDK.Page.getField("so_contacto");
contactoOV.setValue(orden. ??? ); // I also need the contact_name from the SO
} else {
limpiaCampospresupuesto();
}
}
else {
limpiaCampospresupuesto();
}
}
else {
limpiaCampospresupuesto();
}
function limpiaCampospresupuesto() {
var direnvio = ZDK.Page.getField("envio_direccion");
direnvio.setValue(null);
var contactoenvio = ZDK.Page.getField("envio_contacto");
contactoenvio.setValue(null);
}