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 alert function running twice in my script

(0) ShareShare
ReportReport
Posted on by 830

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);
}
);

  • Ravi Fulani Profile Picture
    830 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

  • 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
    830 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.

  • 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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans