Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

[Bug]Cannot prevent save action for "Save and Close" command

Posted on by Microsoft Employee

Hi,

For javascript customization, when we decide to prevent user’s save action after some validations.

It works for “Save” button, but not for “Save and Close” button on create form.

It still continue to close:

4572.Untitled.jpg

SDK reference:

function preventSave(econtext) {

    var eventArgs = econtext.getEventArgs();

    eventArgs.preventDefault();

}

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Could not prevent save action for "Save and Close" command

    actually what I described is that the preventDefault() function only prevent "Save" part of "Save and Close" command.

  • Akanksha Ranjan Profile Picture
    Akanksha Ranjan 460 on at
    RE: Could not prevent save action for "Save and Close" command

    Hi jtxd,

    I think you need to apply the same js onClick on ribbon button "Save and Close".

    Please use ribbon customization for this.

    Thanks

    P.S: Please mark the answer as verified, if found helpful.

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Could not prevent save action for "Save and Close" command

    Hi ,

    Try to check save mode and then return and  prevent.

    Please refer below -

    msdn.microsoft.com/.../gg509060.aspx

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans