Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

328
Vistas
preventDefault not working correctly Dynamics 365

I am trying to get my form to give an alert and prevent save if it meets a certain criteria (the if statement) and save if anything else but if I stick preventDefault inside the IF it still allows me to save.

I have tried putting it outside the IF but then no matter what I can't save the form and my formContext.data.save() doesn't work.

function denyCreateVariationSor(executionContext)
{
    debugger;

    var id = Xrm.Page.getAttribute("gilm_variation").getValue()[0].id;
    
    var url = 'gilmartins-test.crm11.dynamics.com/.../gilm_variations eq ' + id + ')';
    var variationStatus;
    
    var formContext = executionContext.getFormContext();
    
    fetch(url).then(response => response.json()).then(data =>
    {
        var arr = data.value;
        variationStatus = arr[0]["gilm_variationstatus"];

        if (variationStatus != 870110000)
        {
            executionContext.getEventArgs().preventDefault();
            alert("You can't add a SOR onto a completed/cancelled variation");
        }
        else
        {
            formContext.data.save()
        }
    });
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda