Hi,
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.
Please can someone help?
Thank you
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()
}
});
}