Hello everyone
Currently we have a plugin, that opens up a new window, allows users to enter data & then our connector passes this information back to CRM
Upon closing of the window, the code should refresh the record it was launched from. This is the original web resource script that has always worked since 2011
setInterval(function() {
if(name.closed) {
location.reload();
}
}, 2000);
if ( name == "null") { alert("Sheet did not open in a new window, probably due to popup blockers.");}
However in 2013 and 2015, if you run our plugin from a new record, when it refreshes the record, It creates a new one, rather than refreshing the saved opportunity. I believe I need to use the xrm.page.data.refresh() function instead.
The problem comes when I modify the code above to
setInterval(function() {
if(name.closed) {
xrm.page.data.refresh();
}
}, 2000);
if ( name == "null") { alert("Sheet did not open in a new window, probably due to popup blockers.");}
When the window is closed, it does indeed refresh the record. The problem is, it refreshes it continuously and gets trapped in a loop. Due to the fact that the setInterval is set to occur every 2 seconds.
I wish to run the function only once, but i've used setTimeout and I don't know whether it's because the window is closed, but the refresh of the crm record does not occur.
Any suggestions to get round this issue are welcome.