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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Javascript not working on confirm dialog box of save form

(0) ShareShare
ReportReport
Posted on by 836

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;

I have the same question (0)
  • Suggested answer
    Wahaj Rashid Profile Picture
    11,321 on at

    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.

  • Suggested answer
    Charles Abi Khirs Profile Picture
    3,569 on at

    Hello,

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

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 46 Most Valuable Professional

#2
Pallavi Phade Profile Picture

Pallavi Phade 33

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 28 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans