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 / Dependant pcf sub grid...
Power Apps
Unanswered

Dependant pcf sub grid control refresh

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Can we execute a java script (formcontext.data.refresh) from with in a pcf sub-grid control or from outside.

I have a scenario where I have 2 PCF Subgrids when  a record is added to one I want to update the other pcf subgrid

I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

    PCF controls do not have direct access to the client script libraries, but you can still accomplish your objective, just indirectly.

     

    PCF #1 is a dataset control, but you can still bind it to fields as output values. Pick a field on your form (or make a new one for the purpose) that PCF #1 can write a value to in order to announce success. Then set that same field as the bound input for PCF #2 (that is, make PCF 2 a Field type control, not a dataset control) When the field gets updated, PCF2's updateView will get called, and you will know to fire a RetrieveMultiple to update your 'grid'

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @RishiBhutani , 

     

    My first thought was to try some form scripting, use some grid events to attach to selection on the first and refresh the second dataset using the sdk for the GridControl. Unfortunately I didn't had the time to try it out (I guess the problem is to detect if a record was added).

     

    Second thought would be to use standard JS (window.postMessage) like in my older blog (https://dianabirkelbach.wordpress.com/2020/05/15/can-pcfs-communicate/) but this requires that both PCFs are self made and I'm not so sure if it's supported (I consider it a gray zone). The idea would be that the first PCF knows about adding the record, sends a message, and the secons PCF listens to the message and triggers a refresh its the own dataset.

     

    @cchannon : the idea with an output parameter is interesting. According to the docs, the parameters are only of usage input or bound: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/manifest-schema-reference/property#properties.  I've seen the output parameters only on CanvasApps. Have you tried out the output parameter in model-driven apps? 
    In case the output parameters are working, then I would go with your idea regarding the PCF#1, but I wouldn't change the second PCF to a field type PCF (since we loose quite a few functionality provided by the framework). Instead I would use form scripting, register it to "onChange" of the output parameter of the PCF#1, and use form scripting to refresh the second PCF (formcontext.data.refresh as @RishiBhutani mentioned) .

     

    Hope this helps!

     

    Kind regards,

    Diana

  • cchannon Profile Picture
    4,702 Moderator on at

    TBH @DianaBirkelbach, you've got me there, and I will be doing some testing on my own to check. It is entirely possible I have never actually used a non-bound output param other than in the context of a canvas app. I will let you know what I find.

    Also, I completely agree with your tweak at the end there. Using a formscript event to refresh the grid is an objectively better way to trigger the dataset PCF as opposed to rewriting it as a field PCF. Nice call!

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 765 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 272

Last 30 days Overall leaderboard