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)

Immediate auto save of a form

(0) ShareShare
ReportReport
Posted on by

Hi,

My client requirement is, if i change data in an lookupfield the must must save immediately automatically. I tried with 

function preventAutoSave(econtext) {

var eventArgs = econtext.getEventArgs();

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

eventArgs.preventDefault();

}

}

but its nor working can any one help me out

Regards, and Thanks.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I'm sorry but this code breaks the save. If you want to save data immediately after field was updated you should use something like following:

    Xrm.Page.data.entity.save();

    Check this article - msdn.microsoft.com/.../gg334720.aspx

  • Turlapati Vishnu Nandan Profile Picture
    336 on at

    On change of the field the save method as mentioned by Andrii can be called.

  • Clem Profile Picture
    2,541 on at

    Hi,

    Here the eventArgs.PreventDefault() will block the save and not save it.
    I'm not i understood your need, do you need to save or prevent the saving ?

    If you want to save, you add an OnChange event on the lookup fields and trigger a method which will run :

    Xrm.Page.data.save();

    if you want to prevent the autosave, then you should go with : 

    var saveEvent = event.getEventArgs();
    if (saveEvent && saveEvent.getSaveMode && saveEvent.getSaveMode() === 70) {
    return false; // Don't alert on autosave
    }

    where event is your "econtext" so it's pretty much the same.
    How do you call this function ?

    Clément

  • Community Member Profile Picture
    on at

    I need to save my form at onchange event

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    If you need to save a form you should use script I provided in my reply. Good luck.

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