Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Javascript not executing on "Save and Close"

(0) ShareShare
ReportReport
Posted on by

I have some custom javascript on a form that executes on change of the "Created On" field. I did it this way because I only wanted this particular function to execute once, on creation of the record, and not on save. This works great when the user fills out the form, then clicks "Save", but it does not execute if the user clicks "Save and Close". Does anyone know a way to handle this issue? Thanks in advance for any help.

*This post is locked for comments

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,401 on at
    RE: Javascript not executing on "Save and Close"

    Are you checking form type and getSaveMode within JavaScript?

    Xrm.Page.ui.getFormType();
    as well as Save mode as used in AutoSave prevent script.
    function preventAutoSave(econtext) {
        var eventArgs = econtext.getEventArgs();
        if (eventArgs.getSaveMode() == 70 || eventArgs.getSaveMode() == 2) {
            eventArgs.preventDefault();
        }
    }

    https://msdynamicscrmblog.wordpress.com/2013/12/11/get-form-types-and-modes-in-dynamics-crm-2013/

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,401 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans