{Scripting Tip} Refresh form on save in CRM 2015/2016

CRM makes you re-learn your tricks of the game with each version. I had written this workaround for refreshing CRM 2013 form when the trick we guys used to use stopped working for CRM 2011:

https://dynamicsofdynamicscrm.com/2014/04/03/refresh-crm-2013-form-using-script/

This time I was suggesting this workaround for CRM 2015 and It would just not work for Save.

We ended up in a loop of refreshes for the form:

clip_image001

Well, no worries here is CRM 2015/2016 compatible solution:

· Add Modified on to your form

· Add following on change function to Modified on field on the form.

function onChangeModifiedOn()

{

//Needed to set form dirty to false explicitly as it is not done by platform

Xrm.Page.data.setFormDirty(false);
var Id = Xrm.Page.data.entity.getId();
Xrm.Utility.openEntityForm(“entityname”, Id);

}

Note: This has to be only triggered for existing form types, This will not work on Create mode.

This will solve your problem and save the day for you. Hope it helps and Happy CRMing!

Follow me on social channels:

Twitter: https://twitter.com/msdynamicsblog
LinkedIn: https://www.linkedin.com/in/deepesh-somani-00296932

Google Play Store:https://play.google.com/store/apps/detailsid=com.dynamicsofdynamicscrm.msdynamicsblog&hl=en

Advertisement

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s