There are two field in the account form named "gst no" & "pin code". we have added a java script code where it will check that "gst no" & "pin code" is already exists or not in the accounts database if it already exists then the field value will be blank against on change event,this code is running successfully,so after the on change event code running successfully the value of those field remains blank but when we click the "save" button it is getting saved.But we want to restrict the "save " button here only. Our requirement is if the "gst no" & "pin code" value remains blank then the form will not be saved. i'm attaching the code which i have written against "on save" button.
function fnTest(econtext)
{
var Cat1 = Xrm.Page.getAttribute("new_gstno").getValue();
var Cat2 = Xrm.Page.getAttribute("address1_postalcode").getValue();
if(Cat1==null && Cat2==null)
{
if(econtext != null && econtext.getEventArgs() != null)
{
alert("Please Provide a different GST Number and Pin code");
var eventArgs = econtext.getEventArgs();
if(eventArgs.getSaveMode() == 1 || eventArgs.getSaveMode() == 2 || eventArgs.getSaveMode() == 70)
{
eventArgs.preventDefault();
}
}
}
}
*This post is locked for comments