Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

325
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda