Bypassing Prompt and Refresh the Form
In some scenarios of client site scripting in MS CRM 2011 (mostly in the custom ribbon button actions), we might have to force the form to refresh in order to show the updated values or refresh the Enable/Disable Show/Hide status of the ribbon buttons.
But sometimes, just triggering the window.location.reload cause the prompt and prevent the form from refreshing if the user has changed any of the values on the form before triggering the ribbon button event.
In order to avoid such prompt, we can check the Dirty state of the form and force to save if the user has updated any field. And simply refresh the form if there is no change done.
But sometimes, just triggering the window.location.reload cause the prompt and prevent the form from refreshing if the user has changed any of the values on the form before triggering the ribbon button event.
In order to avoid such prompt, we can check the Dirty state of the form and force to save if the user has updated any field. And simply refresh the form if there is no change done.
function ForceRefreshForm()
{
if(Xrm.Page.data.entity.getIsDirty())
Xrm.Page.data.entity.save();
else
window.location.reload(true);
}
Comments
Post a Comment