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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Display subgrid on for...
Power Apps
Answered

Display subgrid on form with filtered view of records from same table

(0) ShareShare
ReportReport
Posted on by 53
In my model-driven app I have a table called Price Change.  It has a field called Product ID. 
 
On the form used to create a new Price Change record I would like to display a readonly sub-grid with all existing Price Change records (ie records from same table) where Product ID matches the value I have entered as I am creating the new record.  I have tried numerous ways using javascript function triggered from when the Product ID field is changed but I cant find a way to dynamically filter the subgrid.  Does anyone know how I can do this?
I have the same question (0)
  • Verified answer
    dmorland Profile Picture
    53 on at
    I found a working solution using this method to update the data in the subgrid
     
       
       const subgrid = formContext.getControl("PreviousPriceGrid");

       // Define filtered FetchXML
       const fetchXml = `
       <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
         <entity name='cr123_pricechange'>
           <attribute name='cr123_productid'/>
           <attribute name='cr123_productname'/>
           <attribute name='cr123_effectivefrom'/>
           <attribute name='cr123_newprice'/>
           <order attribute='cr123_efffectivefrom' descending='true'/>
           <filter type='and'>
             <condition attribute='cr123_productid' operator='eq' value='${productId}'/>
           </filter>
         </entity>
       </fetch>`;
     
     console.log("Applying custom view to subgrid...");
     
     try {
         if (!subgrid) {
             console.log("Subgrid 'PreviousPriceGrid' not found.");
             return;
         }
     
         subgrid.setFilterXml(fetchXml);
         subgrid.refresh(); // Refresh to apply the filter
         console.log("Filter applied successfully.");
     } catch (e) {
         console.error("Error applying filter:", e);
     }

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard