Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

UI D365CRM on-premise

(0) ShareShare
ReportReport
Posted on by 8

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 Microsoft Employee 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 8 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 Microsoft Employee on at
    RE: UI D365CRM on-premise

    Hi PS10,

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans