Hi,
Using “executionObj.getEventArgs().preventDefault()”, we can only prevent CRM form from saving.
However if you want to prevent form from closing then you can add an notification on any field on the same form using below code.
function preventFormClose() {
//setting notification on field to prevent close
Xrm.Page.getControl(arg).setNotification(message,uniqueId)
setTimeout(function(){
//clearing notification from field so that user can make changes and save the changes again
Xrm.Page.getControl(arg).clearNotification(uniqueId) } ,2000);
}
}
The notification prevents the CRM form from saving and also prevent closing the form.
Dynamics CRM MVP |
Inogic | http://inogic.blogspot.com|
news at inogic dot com
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"