Skip to main content

Posts

Showing posts from September, 2016

Refresh CRM 2016 Form after record save using JavaScript

      I had a need to refresh crm 2016 form right after initial save. Surprisingly all good old solution from my archive were not effective in crm 2016. Neither window.location.reload(), nor sdk’s refresh, nor trivial setTimeout. "setTimeout" would work if not bunch of heavy plugins and JavaScrippt validation on save event.     I found that Google knows about it as many as I do. Okay, no copy past this time J     After half an hour I found a nice solution with really minimal risk of browser leaking. The idea based on fact that OnLoad event occurs without form refresh right after change of form type. We need an independent flag to catch that. The code below does the trick. function refreshFormAfterInitialSave() { if (Xrm.Page.ui.getFormType() == 1) { top.callN = 1; } if (Xrm.Page.ui.getFormType() == 2 && top.callN == 1) { setTimeout(function () { top.callN = null; Xrm.Utility.openEnti