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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Navigating away from form saves the form? Any way to prevent this?

(0) ShareShare
ReportReport
Posted on by

Hi everyone!

I have a form with some lookup fields . When i click on a lookup field it automatically goes to the related entity. I get a popup alerting me if i want to stay on the form or not , but if i click to leave the form it automatically saves the form. 

I also have a script preventing save when some values are empty but it seems to override this , because my script works only on save of the form. My solution would be to hidden a field which is required to have a value. When the conditions are all met that field would get a value and so the save would be ok or if it is empty to get a message regarding the required field.

However is there a way to alter this functionality by CRM?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Have you prevented the main form from auto save? or just calling the script function only to validate few values on save? If you have not prevented from auto save, Please use the below function.

    function preventAutoSave(econtext) {

       var eventArgs = econtext.getEventArgs();

       if (eventArgs.getSaveMode() == 70) {

           eventArgs.preventDefault();

       }

    }

    Call "preventAutoSave" function in Form -> OnSave event. Also you need check include the context as first parameter. Then add your JavaScript function in the OnSave event.

  • Suggested answer
    Community Member Profile Picture
    on at

    You can disable the auto save function via the system settings.

    Auto save can be helpful and can be devil =D

  • Community Member Profile Picture
    on at

    Even though i had the command preventDefault() on my condition to check for some fields , adding this script actually worked. Thank you!

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans