web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Verified answer
    Sreevalli Profile Picture
    3,264 on at

    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

       });

  • Radhika Thadivaka Profile Picture
    25 on at

    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
    Guido Preite Profile Picture
    54,086 Moderator on at

    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

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    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
    Sreevalli Profile Picture
    3,264 on at

    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

  • Suggested answer
    Radhika Thadivaka Profile Picture
    25 on at

    [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]

  • Suggested answer
    Radhika Thadivaka Profile Picture
    25 on at

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans