Some time we need to validate based on their input values and need to close crm form if they are not validated, we can do this validation through plugin but, we can’t close form through plugin. So Javascript comes in picture here. We can do this through JS code. To close ms crm form we have close method available, we can use it like below
Xrm.Page.ui.close();
But if you will use this statement, you will get a prompt like below
to stop this prompt you need to use getSubmitMode method of attribute and need to set submitMode to never like below
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes)
{ attributes[i].setSubmitMode(“never”); }
Xrm.Page.ui.close();
Hope it will help somebody!!!
Thank you so much for the script to stop the prompt.. I was struggling for this..
Thanks again ..
Regards
Chandan
I am glad it helped you !!!
I really mean it, thank you o lot
Thanks alot for your help I used to do this in CRM 4 using window.close();
but after upgrade it stopped working, so this will be very helpful
I am still getting the popup window
Did you try to debug you code and checked attribute’s setsubmitmode property value ??
Code was fine, but now I got another message “Are you sure, that you want navigate away from the page” 🙂
Big fanks from RUS )
Much appreciated
Hello,
If i will set submitmode to never then on save method my changes will not save.
do you have any idea ?