Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Error Handling
Unanswered

Editable Grid onchange Help - formContext.getcontrol() not working

(0) ShareShare
ReportReport
Posted on by 20
Request: Save editable subgrid records on change
 
I need to implement javascript that will save the edited record, or all records within a subgrid, when fields are modified. This sounds straightforward, but I have been having major issues with formContext.getcontrol being able to even find the subgrid to interact with. It is especially frustrating since I implemented an on load event to ensure the subgrid is available and initialized prior to the script running, and it checked out fine. Here is the code that I am using that is not locating the subgrid:
 
function doSomething(executionContext) {
    var formContext = executionContext.getFormContext();
    }

    var subgridControl = formContext.getControl("ProductInventories");
    
    if (!subgridControl) {
        console.error("Subgrid control 'ProductInventories' not found using formContext.");
        return;
    }

    console.log("Subgrid control 'ProductInventories' found using formContext.");
    // Perform operations on the subgrid
}
 
Any way I have tried to spin this, I get the same error, "Subgrid control 'ProductInventories' found using formContext." Interestingly, the subgrid was indeed found using xrm.page.getcontrol:
 
function doSomething() {
    var subgridControl = Xrm.Page.getControl("ProductInventories");

    if (!subgridControl) {
        console.error("Subgrid control 'ProductInventories' not found using Xrm.Page.");
        return;
    }

    console.log("Subgrid control 'ProductInventories' found using Xrm.Page.");
    // Perform operations on the subgrid
}
 
 
I really just need some suggestions on how to best implement this. For more context, I have a form with the subgrid in question, and several rollup fields on that form that pull data from the editable subgrid. When data is updated in the subgrid, they are not truly saved, which of course causes major issues when those rollup fields need to always be current.
 
 
Please help, thank you!

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Error Handling

#1
stampcoin Profile Picture

stampcoin 58

#2
DS-11051211-0 Profile Picture

DS-11051211-0 20

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 9

Overall leaderboard

Featured topics