Quantcast
Channel: Neil Parkhurst's Groups Activities
Viewing all articles
Browse latest Browse all 1692

JS to reload parent on subgrid change - different for 2016?

$
0
0

I'm using the Dynamics CRM 2016 Workflow Tools Solution to automatically update a rollup field on a parent record when child records are added.  This seems to work fine, but when I'm working in the child subgrid from the parent form, the new rollup value doesn't show up until I manually reload the page.

When I tried this out a while ago on CRM 2015, I was able to put in some JS to refresh the page - something like this:

http://andreaswijayablog.blogspot.ca/2011/08/refresh-form-after-subgrid-changes-or.html

However, this and other variations I've found and tried no longer seem to work on 2016.  I've tried what seem to be the updated functions/methods:

function Form_onLoad() {
    setTimeout("SubGridRefresh();", 2500);
}
 
function SubGridRefresh() {
    var grid = Xrm.Page.getControl("MySubGrid");
    if (grid) {
        grid.addOnLoad(ReloadForm);
    }
}
 
function ReloadForm() {
    Xrm.Page.data.refresh(true);
}


And no luck.  It gets to the ReloadForm function, but the rollup field still doesn't refresh til I reload manually.  Also tried this code for the reload:

    var id = Xrm.Page.data.entity.getId();
    Xrm.Page.data.save();
    Xrm.Utility.openEntityForm("myEntity", id);


This does reload the page, but it does it even if I try to go to the second page of the subgrid, which makes it not useful at all.

Any thoughts on how I can accomplish this?  (Specifically, the reload when subgrid data is updated.)


Viewing all articles
Browse latest Browse all 1692

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>