We are trying to move to UI from the legacy classic interface and i realise the javscripts those work perfectly on classic interface doesnt work when i switch to UI.
What shall i do, how can i fix these scripts or write new ones that can work for UI interface.
Scripts that are not working are like hid/show tabs, sections.
Note: we are D365 On-premise 9.0
Thanks,
PS10
Hi PS10,
I tested your code on my side and get the same error with yours.(I'm using D365 Online) This is due to the refresh() method would trigger grid.onload() function. Please try this code:
var reload = true;
function Form_onLoad() {
setTimeout("SubGridRefresh();", 2500);
}
function SubGridRefresh() {
var grid = Xrm.Page.getControl("Characteristics");
if (grid) {
grid.addOnLoad(ReloadForm);
}
}
function ReloadForm() {
if(!reload){
return;
}
Xrm.Page.data.refresh(true).then(function success(){
reload = false;
setTimeout(function(){reload = true;console.log("Timeout:" + reload);}, 2500);
}, function fail(error){
console.log(error.message);
});
}
By the way, Xrm.Page is deprecated(Although it can still work), you would better use formContext instead
Hi Steve,
Below is the script where i want to refresh form when a record is added into a subgrid or when it is deactivated, working fine in Classic interface but in UI it keeps on re-loading the subgrid data, like continuous blink, i wrote this after finding some script from internet so any correction to it will be helpful, i do not know how to write jscript my own, we are on-premise 9.0
function Form_onLoad() {
setTimeout("SubGridRefresh();", 2500);
}
function SubGridRefresh() {
var grid = Xrm.Page.getControl("Characteristics");
if (grid) {
grid.addOnLoad(ReloadForm);
}
}
function ReloadForm() {
Xrm.Page.data.refresh(true);
}
Thanks,
PS
Hi PS10,
Could you provide the code which not work on the UI?
André Arnaud de Cal...
291,971
Super User 2025 Season 1
Martin Dráb
230,846
Most Valuable Professional
nmaenpaa
101,156