Skip to main content
Dynamics 365 Community / Forums / Sales forum / UI D365CRM on-premise
Sales forum
Suggested answer

UI D365CRM on-premise

editSubscribe (0) ShareShare
ReportReport
Posted on by 426

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

  • Suggested answer
    Community Member Profile Picture
    Community Member UG Leader on at
    RE: UI D365CRM on-premise

    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

    https://itsfascinating.com/d365/tag/xrm-page-context

  • PS10 Profile Picture
    PS10 426 on at
    RE: UI D365CRM on-premise

    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

  • Community Member Profile Picture
    Community Member UG Leader on at
    RE: UI D365CRM on-premise

    Hi PS10,

    Could you provide the code which not work on the UI?

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,030 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans