Skip to main content

Notifications

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

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: formload from subgrid in UI

    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

  • Lee-Martin Profile Picture
    515 on at
    RE: formload from subgrid in UI

    Got it, the execution context wasn't selected.

  • Lee-Martin Profile Picture
    515 on at
    RE: formload from subgrid in UI

    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.

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: formload from subgrid in UI

    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
    RE: formload from subgrid in UI

    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
    RE: formload from subgrid in UI

    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
    RE: formload from subgrid in UI

    "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
    RE: formload from subgrid in UI

    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
    RE: formload from subgrid in UI

    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();

    }

  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: formload from subgrid in UI

    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

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 the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

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

#1
Siv Sagar Profile Picture

Siv Sagar 149 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 67 Most Valuable Professional

#3
Mansi Soni Profile Picture

Mansi Soni 64

Overall leaderboard

Product updates

Dynamics 365 release plans