Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Javascript alert function running twice in my script

(0) ShareShare
ReportReport
Posted on by 814

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
    Ravi Fulani 814 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
    PabloCRP 1,086 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
    Ravi Fulani 814 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.

  • 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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans