web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

formload from subgrid in UI

(0) ShareShare
ReportReport
Posted on by 515

Has anybody had any issues with using formload with a subgrid?

I've a page which runs JavaScript based on a subgrid being updated, and it doesn't seem to be working since we've been forced to move to UI.

Thanks

Lee

I have the same question (0)
  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    How did you add js functions to subgrid onload events?

    You could try the following code:

    Foe example I have an account subgrid on my form.

    function subgridOnload(executionContext){
        var formContext = executionContext.getFormContext();
        var gridContext = formContext.getControl("CustomGird");
        
        gridContext.addOnLoad(onloadFunction);
    }
    function onloadFunction () { 
        alert("Subgrid onload now!");
    };

    pastedimage1571191894968v2.png

    Note that you need to type in the correct subgrid name, not label.

    pastedimage1571191690173v1.png

    You could refer to this doc for more details.

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/grids/gridcontrol/addonload

    Hope it helps.

    Best Regards,

    Leo

  • Lee-Martin Profile Picture
    515 on at

    The only thing  I've changed is the switch to Unified Interface. The code was working as expected in classic look.

    function formload() {

       var GridOnloadFunction = function() {

           SubgridModifed();

       };

       //Check if the grid is loaded and add the event handler to the subgrid.

       var checkgrid = window.setInterval(function() {

           if (Xrm.Page.getControl("DebitCards") != null) {

               Xrm.Page.getControl("DebitCards").addOnLoad(GridOnloadFunction);

               window.clearInterval(checkgrid);

           }

       }, 2000);

       var checkgridCredit = window.setInterval(function() {

           if (Xrm.Page.getControl("CreditCards") != null) {

               Xrm.Page.getControl("CreditCards").addOnLoad(GridOnloadFunction);

               window.clearInterval(checkgridCredit);

           }

       }, 2000);

    }

    function SubgridModifed() {

      firstFunction();

      secondFunction();

      thirdFunction();

      Xrm.Page.data.entity.save();

    }

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    "Xrm.page" is no longer supported in UI, so please use "executionContext" instead like the code I provided above.

    Best Regards,

    Leo

  • Lee-Martin Profile Picture
    515 on at

    "Xrm.page" is no longer supported in UI

    Ah thank you.

    Is there a list anywhere of everything that is no longer supported in UI?

    We keep finding these things, and we don't have the time or resource to hunt down everything that was working as required in the classic look before being forced onto UI.

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    Here's a doc for you.

    pastedimage1571216531965v1.png

    https://docs.microsoft.com/en-us/power-platform/important-changes-coming

    Hope it helps.

    Best Regards,

    Leo

  • Lee-Martin Profile Picture
    515 on at

    Where do I call this function from?

    I've added it to my form's onload and it's not calling the function. My first line is a console log and it's not outputting.

    function subgridOnload(executionContext){

    console.log("in subgrid onload");

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    Yes, just add it to form "onload" event.

    If there is no outputting, please use F12 to open the development tools and check if there is any error message, you could also debug your code to check if the function triggered.

    If the code you provided above is the same in your event, then it miss a "}" at the last position.

    pastedimage1571217726287v2.png

    pastedimage1571217701534v1.png

    Hope it helps.

    Best Regards,

    Leo

  • Lee-Martin Profile Picture
    515 on at

    I've used F12 development - it's why I can see the console.log hasn't been activated.

    The code has been validated in an online validator and is validated correctly.

    The code is simply not being called.

  • Lee-Martin Profile Picture
    515 on at

    Got it, the execution context wasn't selected.

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    Yes, we should select "pass executionContext....." when we add it to events.

    I'm so glad that you've resolved your problem.

    If my answer helped you, please mark my answer as verified so that we choul help other users with similar issues.

    Best Regarsds,

    Leo

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans