Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Alert dialog box with yes or no options in Dynamics 365

(0) ShareShare
ReportReport
Posted on by 25

Hi all,

I am very new to Java script and i am trying to develop a alert box with yes or no option

After filling the appointment form and saving it then an alert box must be displayed with the options yes / no

If user selects "yes" then appointment must be sent and if "no" dont send the appointment nor  save the record

*This post is locked for comments

  • Suggested answer
    RE: Alert dialog box with yes or no options in Dynamics 365

    Thank you so much for srivalli,Guido Preite and Goutam.Your suggestions helped me well.

  • Suggested answer
    RE: Alert dialog box with yes or no options in Dynamics 365

    [quote user="Radhika Thadivaka"]

    Hi all,

    I am very new to Java script and i am trying to develop a alert box with yes or no option

    After filling the appointment form and saving it then an alert box must be displayed with the options yes / no

    If user selects "yes" then appointment must be sent and if "no" dont send the appointment nor  save the record

    [/quote]

  • Verified answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: Alert dialog box with yes or no options in Dynamics 365

    Hi,

    To use the below line,

    executionContext.getEventArgs().preventDefault();

    You should pass the executionContaxt in your function parameters, then only it will have the memory of context to work on your preventdefault method.

    Checkout Goutam’s code

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Alert dialog box with yes or no options in Dynamics 365

    Hi,

    Your code is correct just to add parameter execution context  and pass the executioncontext from event handler  -

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/clientapi-execution-context

    function onSave(executionContext) {
        if ((Xrm.Page.getAttribute("requiredattendees").getValue() != null) || (Xrm.Page.getAttribute("optionalattendees").getValue() != null) || (Xrm.Page.getAttribute("subject").getValue() != null)) {
            var confirmStrings = { text: "An Outlook invitation will now be sent out to all selected participants. Do you wish to proceed?", title: "Outlook Invitation" };
            var confirmOptions = { height: 200, width: 450 };
            Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
                function (success) {
                    if (success.confirmed) {
                        console.log("Dialog closed using OK button.");
                    }
                    else {
                        executionContext.getEventArgs().preventDefault();
                    }
    
                }
            );
        }
    }
  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,069 Super User 2024 Season 1 on at
    RE: Alert dialog box with yes or no options in Dynamics 365

    you are using executionContext but your function does not have the executionContext as parameter, it should be

    function onSave(executionContext) {

    and you need to select "pass execution context as first parameter" in the onsave function handler when you add the function to the onsave event

  • RE: Alert dialog box with yes or no options in Dynamics 365

    Hi sreevalli,

    Thank you for sharing the code.

    I implemented the code like this for appointment entity which displays an dialog box after saving the form,

    on the dialog box i am able to see the cancel and ok button .clicking on the ok closes the box but the record is being saved even though i click cancel.

    Please help me

    function onSave() {

       if ((Xrm.Page.getAttribute("requiredattendees").getValue() != null) ||

           (Xrm.Page.getAttribute("optionalattendees").getValue() != null) ||

           (Xrm.Page.getAttribute("subject").getValue() != null))

       {

       var confirmStrings = { text: "An Outlook invitation will now be sent out to all selected participants. Do you wish to proceed?", title: "Outlook Invitation" };

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

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

           function (success) {

               if (success.confirmed)

                   console.log("Dialog closed using OK button.");

               else

                   executionContext.getEventArgs().preventDefault();

           }

           );

       }

    }

  • Verified answer
    Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: Alert dialog box with yes or no options in Dynamics 365

    Hi,

    see the sample code for confirmation window

    var confirmStrings = {

       text: "Do you want to clone this Quote and Proposed Vessels.", title: "Please Confirmation",

       subtitle: "", "cancelButtonLabel": "Cancel", confirmButtonLabel: "Confirm"

    };

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

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

       function (success) {

    //add your logic

       });

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans