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

Community site session details

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

Javascript alert function running twice in my script

(0) ShareShare
ReportReport
Posted on by 834

It seems my JS is running twice when I have called it only once that is on save, I have used alert dialog box and this alert dialog box comes twice so i am not able to understand why this problem is coming can anyone help below is the code that i have used.
context.getEventArgs().preventDefault();
var alertStrings = { confirmButtonLabel: "Yes", text: "Please complete the Technical Evaluation First and Mark 'Technical Evaluation Completed' field as Yes.", title: "Booking Alert: ERROR" };
var alertOptions = { height: 120, width: 260 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
function (success) {
console.log("Alert dialog closed");
},
function (error) {
console.log(error.message);
}
);

I have the same question (0)
  • LB-04061101-0 Profile Picture
    on at
    RE: Javascript alert function running twice in my script

    Hello Ravi,

    I would suggest to add a debugger statement in the code and use the Developer tool create a breakpoint to debug. More details on docs.microsoft.com/.../debugger

    Luis

  • Ravi Fulani Profile Picture
    834 on at
    RE: Javascript alert function running twice in my script

    Hi  @Luis Boal

    I did try that and it ran twice so I am lil bit not able to understand the reason.

  • Suggested answer
    PabloCRP Profile Picture
    1,088 on at
    RE: Javascript alert function running twice in my script

    "The form saves every 30 seconds so it can cause plug-ins, workflows, or JavaScript to trigger when you may not want them to"

    pastedimage1606333814895v1.png

    it raises twice because at the time you are debugging the autosave already happend.

    So turn it off.

    more info...

    1- MSDocs

    2- Auto Save Form

    regards.

    Don't forget to mark as an answer if it was helpfull

  • Ravi Fulani Profile Picture
    834 on at
    RE: Javascript alert function running twice in my script

    Auto save is already No in my system, That is the reason I am confused that such simple code which shows only an alert why it is running twice

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 169

#2
André Arnaud de Calavon Profile Picture

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

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 67

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans