Hi All,
I have a requirement for refreshing the CRM home grid based on a button click.
I have added custom button and java script on the home grid of my entity, when a user clicks on the button the script will do some business logic and after that I need to refresh the home grid.
I already tried the following code for achieving the same but it is not working. It is showing an error 'Unable to get property 'document' of undefined or null reference'
"window.parent.opener.document.getElementById("crmGrid").control.refresh();"
Can anyone help me ...
Thanks
Abhiram
*This post is locked for comments
Hi, you can try to get the IFRAME id of the home grid and do a refresh.
try{
parent.document.getElementById('contentIFrame0').contentWindow.document.getElementById('crmGrid').control.refresh();
} catch (e0) { }
try{
parent.document.getElementById('contentIFrame1').contentWindow.document.getElementById('crmGrid').control.refresh();
} catch (e1) { }
try {
parent.document.getElementById('contentIFrame2').contentWindow.document.getElementById('crmGrid').control.refresh();
} catch (e2) { }
Hi Abhiram,
Use timeout conecpts. You are trying access that grid not yet ready.
function Form_OnLoad() {
setTimeout(subGridA_OnLoad, 1000); //We're using setTimeout() here because subgrids are loaded after $(document) is ready.
}
function subGridA_OnLoad() {
var subgridA = document.getElementById("subgridA");
subgridA.attachEvent("onrefresh", RefreshSubgridB);
}
function RefreshSubgridB() {
var subgridB = Xrm.Page.ui.controls.get("subgridB");
subgridB.refresh();
}
Hope this will help you . :)
Thanks
Hemant Kumar
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,836
Most Valuable Professional
nmaenpaa
101,156