How to get event for ‘x’ button of openConfirmDialog()

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.


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
  • 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!!!

6 thoughts on “How to get event for ‘x’ button of openConfirmDialog()

  1. 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?


  2. 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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s