Search code examples
dynamics-crmdynamics-crm-2016

Refresh Parent Form after Quick Create in Dynamics CRM 2016


In Dynamics CRM 2016 we have a Quick Create Form which works well. But once the Quick Create is done, and the record is saved (and the new record appears in the sub-grid in the parent form), the roll-up field under the sub-grid doesn't get re-refreshed on the screen until the user presses F5.

(we have some C# code to update the roll-up).

Does anyone know how to force the refresh of the main form after the Quick Create has successfully run?

enter image description here


Solution

  • You may add timeout on refresh event, and after 1-2 sec refresh once more.

    function OnFormLoad() //add this function onload form
        {
          var subGrid = window.parent.document.getElementById("id of your subgrid")
          if (subGrid !== null) {
            if (subGrid.control)
              subGrid.control.add_onRefresh(fnOnRefresh)
            else
              setTimeout(OnFormLoad, 500);
          } else {
            setTimeout(OnFormLoad, 500);
          }
        }
    
    function fnOnRefresh() {
          setTimeout(function() {
            Xrm.Page.ui.controls.get("id of your subgrid").refresh();
          }, 2000) //after 2 sec refresh subgrid
        }