Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

On clicking of Esc button for Xrm.Navigation.openAlertDialog goes to success call back .

Posted on by 350

I have scenario to show alert dialog and on click of OK should navigate to view in CRM .

For this I have used Xrm.Navigation.openAlertDialog everything works good when I click on OK it navigates to view but on click of Esc or Close(X) button it again showing the same behavior as OK button like Opening the view which is causing infinite loop .

Presently I have used Window.open to open different page for entity View but similar thing is happening when I press Close button for Xrm.Navigation.navigateTo method also .

I have used the same code as mentioned below ..

var alertStrings = { confirmButtonLabel: "Yes", text: "This is an alert.", title: "Sample title" };
var alertOptions = { height: 120, width: 260 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
    function (success) {
        window.open("----THIS WILL HAVE VIEW "----);
    },
    function (error) {
        console.log(error.message);
    }
);

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,321 Most Valuable Professional on at
    RE: On clicking of Esc button for Xrm.Navigation.openAlertDialog goes to success call back .

    Your code looks ok for me but just in case try to use the following code instead:

    var confirmStrings = { text:"Please close appointments", title:"Open Appointments" };

    var confirmOptions = { height: 200, width: 450 };

    Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(

    function (success) {    

      if (success.confirmed) {

         window.open("MY VIEW URL");

      }

    });

  • Sai Chaitanya Profile Picture
    Sai Chaitanya 350 on at
    RE: On clicking of Esc button for Xrm.Navigation.openAlertDialog goes to success call back .

    Here is the code

    var confirmStrings = { text:"Please close appointments", title:"Open Appointments" };

    var confirmOptions = { height: 200, width: 450 };

    Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(

    function (success) {    

       if (success.confirmed)

          window.open("MY VIEW URL");

       else

    });

    I dont have much use of this one but pretty much confused why clicking on X mark to close dialog still opens up my View in using Window.open...

  • a33ik Profile Picture
    a33ik 84,321 Most Valuable Professional on at
    RE: On clicking of Esc button for Xrm.Navigation.openAlertDialog goes to success call back .

    I'm afraid you would not be able to use alert for your scenario. Can you please provide the code that you used with openConfirmDialog that doesn't work?

  • Sai Chaitanya Profile Picture
    Sai Chaitanya 350 on at
    RE: On clicking of Esc button for Xrm.Navigation.openAlertDialog goes to success call back .

    Thanks But I have specific requirement to show Alert message but even tried openConfirmDialog when I use X button or ESC to close the same behavior happens like navigating to View ...

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,321 Most Valuable Professional on at
    RE: On clicking of Esc button for Xrm.Navigation.openAlertDialog goes to success call back .

    Hello,

    You should try openConfirmDialog instead - docs.microsoft.com/.../openconfirmdialog

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans