Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Javascript not working on confirm dialog box of save form

(0) ShareShare
ReportReport
Posted on by 834

I am using below code, the problem is i am able to unsave the record for one condition and for other saving the record is not taking place. Need help with this

if(!saveFromConfirmDialog)
{
context.getEventArgs().preventDefault();
var confirmStrings = { text: "Address is already used by another project.", title: "Duplicate Address Found", confirmButtonLabel:"Save & Continue" , cancelButtonLabel: "Open Project"};
var confirmOptions = { height: 150, width: 450 };
Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
function (success) {

if (success.confirmed) {
saveFromConfirmDialog = true;
formContext.data.entity.save();

}
else{

saveFromConfirmDialog = false;
window.open(url);

}
});

}


saveFromConfirmDialog = false;

  • Suggested answer
    Charles Abi Khirs Profile Picture
    3,569 on at
    RE: Javascript not working on confirm dialog box of save form

    Hello,

    Try to debug your code and check if the variable saveFromConfirmDialog is being properly set by default for this record not being saved.

  • Suggested answer
    Wahaj Rashid Profile Picture
    11,321 on at
    RE: Javascript not working on confirm dialog box of save form

    Hi,

    Thank you for your query.

    When you say you are not able to save the record, what happens? It does not save or it gives error?

    And what is the default value of "saveFromConfirmDialog"? I see problem here.

    Please note, when you save the record programmatically, the same function will be called again, you need to make sure SaveFromConfirmDialog is not reset to true.

    You can add debugger; in top of this function, launch Dev Tools (F12) and debug the code line by line (F10) to verify if formContext.data.entity.save(); is called.

    If it is not the problem, please provide more details.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Adis Profile Picture

Adis 136 Super User 2025 Season 1

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 81

#3
Jonas "Jones" Melgaard Profile Picture

Jonas "Jones" Melgaard 77 Super User 2025 Season 1

Product updates

Dynamics 365 release plans