Saturday, February 11, 2012

MSCRM 2011 javascript validate lead qulify javascript

Sometimes validation of fields is needed before qualifying a lead.
Setting the fields to be required isn't good enough, because there is no need to require the fields for every save.
It can be done using javascript on form save event.

Check if the save mode equals 16 (lead qualify) by using

ExecutionObj.getEventArgs().getSaveMode()

Use prevent default to prevent the page from saving and qualifying.
ExecutionObj.getEventArgs().preventDefault()


Microsoft link about preventDefault
http://msdn.microsoft.com/en-us/library/gg509060.aspx#BKMK_preventDefault

Microsoft link about getsavemode
http://msdn.microsoft.com/en-us/library/gg509060.aspx#BKMK_GetSaveMode

Good wiki that extends more about getsavemode and preventDefault
http://social.technet.microsoft.com/wiki/contents/articles/4122.aspx


1 comment: