Customization · Dynamics CRM 2011 · Javascript

CRM 2011: addOnSave and removeOnSave

There are many situations which requires a custom action to be performed after saving a record. For example: set its status, add a relationship, update a field, update another record, etc.

To be honest, trying to implement a custom action after a save on CRM UI isn’t an easy task. The problem is the form refreshes immediately after a save therefore rendering your code inherently buggy or not working altogether. Most of the time, I turned to Plugins.

These two methods on opened up a whole new possibility with post save custom action as CRM UI automatically handle the execution of javascript method before refreshing the form.

To use it simply:

function addActionToOnSave() {;

function removeActionFromOnSave() {;

function setRecordStatusInactive() {
 //code to set record status inactive

The thing to keep in mind is that after save and the page refreshes, the custom action is reset.

Read more on MSDN here.

Cheers – Sy

PS: The function will be added to the bottom of the event handler pipeline. This means that the function will complete execution before the save is completed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s