Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
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,323 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,323 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,323 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans