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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Confirmation Dialog Box for OnCreate Event

(0) ShareShare
ReportReport
Posted on by

Hello everyone.

I am trying to create a dialog box as a warning to the user when trying to create an entity record in a custom entity.

I wrote a JS which I tried to trigger onSave of form. However, this dialog box is popping up in the loop. This is happening both when I accept or cancel the event. 

function OnFormSave(executionObj) {
    var eventArgs = executionObj.getEventArgs();
    var formContext = executionObj.getFormContext();
  //  eventArgs.preventDefault();

    if (eventArgs.getSaveMode() == 70)//AUTOSAVE
    {
        eventArgs.preventDefault();
        return;
    }

    var confirmStrings = { text: "Are you sure you want to continue to save the record?", title: "Warning" };
    var confirmOptions = { height: 250, width: 500 };
    Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
    function (success) {
        if (success.confirmed)
        {
           // formContext.data.save();
        }
        else {
            eventArgs.preventDefault();
          
        }
    });
}

Can someone help me with this. Also, this event should happen only when the record is create. Any fix for that?

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Try this in the last section.      

     if (!success.confirmed)

           {

              return;

           }

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You should try an approach similar to my post - butenko.pro/.../

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans