Prior to the release of Dynamics CRM 2013, when a save occurred on a CRM form you could reliably expect 2 client side events to fire.
1. OnSave – which occurred just prior to the actual saving of the record.
2. OnLoad – which would fire when the saved record refreshed.


In Dynamics CRM 2013 / Online the latter event does not fire after save, presumably, to avoid lots of refreshes occurring as a result of the new auto save functionality.

Unfortunately, this broke some of our custom javascript functionality that relied on the OnLoad after saving a new record to execute “Update Form” specific functionality.

The most common instance of this in our solutions was loading iFrames with contextual content based on the current record’s ID. During the initial load of the “Create Form”, the iFrame would be left blank, but once the record had an ID (i.e. it was persisted) we’d load the iFrame with our contextual page.

As a workaround to this specific issue you can use the OnChange of the modified field to trigger the code that was running in the OnLoad. This works because saving a new record populates the modifiedon field with the current date and updates it on the form which triggers the OnChange event.

Below is the setup we’ve used for one of these cases. There are 2 iFrames on the form with controls to upload product images for display in our Online Store module.


In the case of the product form we’re not concerned with displaying the modifiedon field so we chose to mark the field as not visible (below left). The OnChange will fire whether the fields is displayed or not.

The only other thing to do in our case was to add the FormLoad function that handles the OnLoad event to the OnChange event of the modifiedon field (below right).


The final product is the same functionality we have in our Dynamics CRM 2011 instances of our product with only minor customization changes and no code changes, which is always a good thing as we continue to support both versions of CRM.

Learn How Cobalt Can Help You with CRM