What is Issue?
While using openConfirmDialog in Xrm, you will be always able write the logic according to ok and cancel button. But some times ‘x’ button will get ignored while development and which will results into code loophole. Also there might be situation when you have to write different logic on ‘x’ and ‘cancel’ button. So how to get the ‘x’ button event?
The Reason-
Microsoft has provided the documentation for openConfirmDialog () with ok and cancel button description. But might be forget to write about ‘x’ button or might be they functionality was inprogress while it was documented.
Solution
If you know ,you can write success callback and error callback function to openConfirmDialog ().then(success(),error());
Success callback function holds the response from user, whether he confirmed or canceled this action. Using same function we can handle ‘x’ button event.
The user response to the confirmation as below-
- Press Ok : success.confirmed
=true
- Press Cancel: success.confirmed
= false
- Press ‘x’ : success.confirmed
= undefined
So in success callback function, use proper conditions to handle logics on these buttons available on openConfirmDialog.
Now according to above code, if I press ‘x’ the result will be as below-
Hope this will help…
Enjoy Ms CRM!!!
Press Cancel: confirmed.success = false
Press ‘x’ : confirmed.success= undefined
I have tried this today. On click of cancel button also confirmed.success is returning the values as undefined. it’s returning false. can you please help me to understand this?
LikeLike
It is success.Confirmed , not confirmed.success
“Success” is variable which we are getting result from our action on confirmDialog box
LikeLike
True I understand. If I click on Ok button I am getting the value in the confirmed.success as true. Where as if I click on cancel and x button both are returning the value as undefined in confirmed.success variable
LikeLike
Sorry instead of success. Confirmed i have typed it as confirmed.success. its typo error from my end.
LikeLike
Might be with new updates, Microsoft has fixed the events on alert message buttons. But it still working on earlier versions of MS CRM.
LikeLike
Thanks, Prashant. I have used custom pop-up and achieved the requirement.
LikeLike