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?

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Confirmation Dialog Box for OnCreate Event

    Hello,

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

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Confirmation Dialog Box for OnCreate Event

    Try this in the last section.      

     if (!success.confirmed)

           {

              return;

           }

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 95

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans