Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Confirmation Dialog Box for OnCreate Event

$
0
0

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?


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images