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 :

Firing on-load event every time when record is saved. Exploring the data onload event in Dynamics v9.0

Debajit Dutta Profile Picture Debajit Dutta 2,702

Recently I was working with a customer and came across a requirement where they needed to fire an event on client side every time once the data is saved successfully to process some post-save operations.

As we all know from version CRM 2013 and onwards the formload event does not fire when save is completed. So what is the other way around?

Well there is way to do that. We need to use the formContext.data.addOnLoad to add an event which fires every time when the data is refreshed.

The below code adds the onLoad event of data refresh in the form load event of the account entity.

function formLoad(e) {
     var formContext = e.getFormContext();

    formContext.data.addOnLoad(dataOnLoad);

    console.log("form load called.");
}

function dataOnLoad(e) {
    // write your code here.
    console.log("data onload fired");
}

formLoad is the event which is registered through Form events. In the formload we are adding the event for data refresh using the formContext.data.addOnLoad method.

The function dataOnLaod fires on the initial page load as well as every time the user clicks on save. And now you have a way to perform your post-save operations in client side whenever the record is saved.

Also please note that the function also fires if formContext.data.refresh() function is called.

Debajit Dutta
(Dynamics MVP)
For consultation/ training visit
http://www.xrmforyou.com or reach out to us at info@xrmforyou.com


This was originally posted here.

Comments

*This post is locked for comments