Hello Everyone,
I'm stuck with this issue in CRM 2013. On-Save Event I'm using the following code for Validation before Lead Qualification. I've also checked to pass execution parameter during the function call On-Save Event.
function FrmOnSave(prmContext)
{
// Local variable to store value indicating how the save event was initiated by the user.
var wod_SaveMode, wod_SaveEventVal;
// Change the Save Event Value as per required Save Event
wod_SaveEventVal = 16;
if (prmContext != null && prmContext.getEventArgs() != null)
{
wod_SaveMode = prmContext.getEventArgs().getSaveMode();
if (wod_SaveMode == wod_SaveEventVal)
{
// Write your validation code here
if(Xrm.Page.getAttribute("industrycode").getValue() == 1)
{
// Use the code line below only if validation is failed then abort function save event
alert("Choose Appropriate Industry Code");
prmContext.getEventArgs().preventDefault();
//var x = prmContext.getEventArgs().isDefaultPrevented();
//alert(x);
}
}
}
}
This is working fine on CRM 2011, But on CRM 2013 it's showing variant results. Like:
1> If I open a lead record and directly click on Qualify button then it Qualifies the Lead without any validation (preventDefault() doesn't seems to work).
2> If I open a Lead form, change any random field value and then click on the Qualify button, it works fine again.
Please help to figure out the issue, Am I missing anything here ?
Thanks, Ashwani