Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Immediate auto save of a form

Posted on by Microsoft Employee

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

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Immediate auto save of a form

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Immediate auto save of a form

    I need to save my form at onchange event

  • Clem Profile Picture
    Clem 2,541 on at
    RE: Immediate auto save of a form

    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

  • RE: Immediate auto save of a form

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

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Immediate auto save of a form

    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

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans