Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How do I modify the fetchXml of a Home Grid for D365 Online?

(0) ShareShare
ReportReport
Posted on by 23
We currently have an onprem installation of Dynamics, v.9.1 where we run a custom javascript when the home grid for account loads.
Then we modify the fetchXml for the homegrid by running the following javascript code:
 
var grid = parent.document.getElementById("crmGrid");
var fetchXml = grid.control.GetParameter("fetchXmlForFilters");
var xmlDoc = $.parseXML(fetchXml);

// here we modify the xmlDoc… Then we modify the fetchXml of the grid:

grid.control.SetParameter("fetchXml", (new XMLSerializer()).serializeToString(xmlDoc));
grid.control.Refresh();

In D365 online the html-structure for the home grid seems to be different than for onprem.
I cannot find any html-element with id "crmGrid", nor any other obvious element that is the grid.
 
Does anyone know if it is possible to achieve the same modification of the grid or is D365 online too different?
The modification of the fetchXml for the home grid gives us a way to give the users some functionality in a format that the appreciate a lot.
We are currently in a project of migrating the onprem to online and I have a feeling it will be a bummer for them if the same functionality cannot be delivered for the home grid.
Categories:
  • Fedorov Profile Picture
    Fedorov 23 on at
    How do I modify the fetchXml of a Home Grid for D365 Online?
    Hello,
    I can see how your suggestion would work on a "form" but in this case, on the "home page", I don't know the id of the grid.
    (also, we use the "Power Apps grid control in this particular environment, I don't know if that makes a difference though)
     
    In the onprem version of Dynamics it seems that the "home page grid" always gets the id "crmGrid".
    But in the online version I cannot find any control that would obviously be a grid.
    The closest I can find is this:
     
    var grid = parent.document.querySelectorAll('[data-type="grid"]')
     
    But the above "grid" does not have a property "control" which means that I cannot perform this code:
    grid.control.SetParameter("fetchXml", (new XMLSerializer()).serializeToString(xmlDoc));
     
    So that's where I'm stuck at the moment..
  • LA-02051057-0 Profile Picture
    LA-02051057-0 23 on at
    How do I modify the fetchXml of a Home Grid for D365 Online?
    Test
  • Suggested answer
    VaHiX Profile Picture
    VaHiX 3,930 on at
    How do I modify the fetchXml of a Home Grid for D365 Online?
    In Dynamics 365 Online, the editable grid control is used instead of the older grid control, and the way to interact with it is different
     
     
    so you need to define control as
    var gridControl = Xrm.Page.ui.controls.getControl("mainGrid"); // Replace "mainGrid" with the actual grid control name
     
    and at last set as:


    gridControl.setFetchXml((new XMLSerializer()).serializeToString(xmlDoc));
    gridControl.refresh();

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,883 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans