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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

I want to call javascript function when ever record is completely saved

(0) ShareShare
ReportReport
Posted on by

I want to call javascript function when ever record is completely saved.So how to do it

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    You will need to register an onchange handler as described here crmtipoftheday.com/.../simulate-onload-event-for-form-updates

    Hope this helps

  • ScottDurow Profile Picture
    21 on at

    How did you get on - did you get it working?

  • Suggested answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Hi Akash,

    You need to call JavaScript onSave event

  • ScottDurow Profile Picture
    21 on at

    Actually the onsave event will not work since this fires *before* the record has been saved - instead of after the record as save completely as the OP wanted.

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Akash,

    Scott is right, the onsave will be callend as prevalidation before save.

    You can place your code in the onload but it doesn't mean will be called only after save.

    And we found the 'unsupported way' using this javascript

    function addOnPostSave(handler) {

       if (window.__Mscrm_save == undefined) {

           window.__Mscrm_save = Mscrm.InlineEditDataService.save;

           Mscrm.InlineEditDataService.save = function (saveMode, succeedCallback, errorCallback, sync, propagateCallbackHandler) {

               var tempsuccesscb = succeedCallback;

               succeedCallback = function (arg1) {

                   if (tempsuccesscb != null) tempsuccesscb(arg1);

                   Xrm.Page.data.setFormDirty(false); for (var i = 0; i < window.__post_save_events.length; i++) window.__post_save_events[i]();

               }

               //var temperrorcb = errorCallback;

               //errorCallback = function (arg1) {

               //    debugger;

               //    if (temperrorcb != null) temperrorcb(arg1);

               //}

               window.__Mscrm_save(saveMode, succeedCallback, errorCallback, sync, propagateCallbackHandler);

           }

       }

       if (window.__post_save_events == undefined) window.__post_save_events = new Array(); window.__post_save_events.push(handler);

    }

    And how to call:

    addOnPostSave(function() { alert('after Save!!'); })

    Remember this is unsupported.

    Thanks

  • Suggested answer
    shivaram Profile Picture
    3,315 on at

    Hi Akash,

    If you register script "OnSave" Then it will trigger while saving.If you want to do after save then you have 2 options.You can follow Aileen Gusni Suggestion

    or simply you can do one thing

    By default we are having "Modified on" field.so add that field into your form(If you don't want to see this field then you can uncheck display option).And register your script on change of "Modified on" field.

    Because modified on field changed when record is completely saved.

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

News and Announcements

Season of Giving Solutions is Here!

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
Shidin Haridas Profile Picture

Shidin Haridas 2

#1
SA-08121319-0 Profile Picture

SA-08121319-0 2

#1
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans