, , , , , , ,

Hello Everyone,

Few weeks back, I got stuck with this Issue in CRM 2013. Actually I wanted to check for some validation before Qualifying a lead. So, during an On-Save Event I used the following JScript code for Validation before Save-Event for Lead Qualification(16). But apparently this doesn’t seems to be working correctly at times.

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");

             //var x = prmContext.getEventArgs().isDefaultPrevented();

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.

Failing to know the exact cause of this behavior I posted this question to the Microsoft Dynamics CRM Social Forum. Many Thanks to MVP Mahender Pal for his quick response as he too found this to be unusual and logged this Issue as a BUG on Microsoft Connect here

If you too have been facing similar Issue or have came across such related to PreventDefault(), request you all to kindly vote for the Microsoft Connect link provided below:-


Note:- Recently Microsoft also updated this Issue as a BUG !!!  Notification of Same can be found on the same link above.

While Microsoft will come back to this in detailed description as a Resolution, I had to complete this task anyhow under my deliverable timeline. So as a workaround I used the new feature of Synchronous Workflow to achieve the above desired Validation as discussed in my Previous Post.

Hope this will be helpful.

Thanks !!!