Hi,
I'm building a dataset PCF control for a model driven app. It will allow the user to select several items from a "picker" and add them to the dataset (i.e. to a Dataverse table). The values for the picker come from an external API not a Dataverse table.
In the PCF documentation I can see there is a function context.parameters.dataset.newRecord() but this only applies to canvas apps. How do I do the equivalent in a model driven app?
Hi @TimRobinson33 ,
True, it's not documented there. I'll try to report to the docs.
But it was always there, and was used inside Canvas Apps/ Custom Pages,
Since a while we can use it inside model-driven apps too.
It's shown in this official example: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/sample-controls/object-output?WT.mc_id=BA-MVP-5004107. I think there are some more examples, so it should be safe to use it.
Hey thanks this is really interesting to see a deeper investigation of how to use some client-side scripting in combination with a PCF control - the MS examples often cover only the easy cases.
I never even heard about
<Property usage="output">
According to the documentation https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference/property property can only be "bound" or "input"
Yes I see what you're getting at. It seems a little complicated so I'm going to see if the users are OK without the auto-refresh, but if we do need it, this gives me a head start on what to do.
Thank you so much
--- Tim
Hi @TimRobinson33 ,
That could be tricky. You need to refresh the other subgrid too, and the only way to do that is by using formScripting on the form containing both subgrids (subgrid and your PCF).
I believe you can achieve that by:
- for your dataset PCF, define another property of usage output. When you need to refresh the other subgrid, change the value of your output property (for instance write a timestamp)
- inside the formScripting for your form hosting the subgrids, use addOnOutputChange on your dataset PCF (https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/controls/addonoutputchange?WT.mc_id=BA-MVP-5004107). There you can read the value using controlForPCF.getOutputs(), in case you need that value https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/controls/getoutputs?WT.mc_id=BA-MVP-5004107
- when the output value changes, use form Scripting to refresh the other subgrid (using the refresh method on your subgrid control: https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/grids/gridcontrol/refresh?WT.mc_id=BA-MVP-5004107)
It's a little harder to explain. Does it make sense to you?
Hi Diana, sorry for the slow response - I got dragged onto another project.
Thanks for your suggestion, it does indeed refresh my control but unfortunately now I have an additional complexity.
On the screen there are actually two separate dataset views of the same sub-table, one is a standard PowerApps subgrid and the other is my PCF control. if I edit in the other subgrid and save then my control is automatically refreshed. However when I call refresh from my control, the other subgrid doesn't update to reflect the records I have just added
Do you know if there is any way to force other datasets on the same sub-table to refresh?
Thanks
--- Tim
Hi @TimRobinson33 ,
You could make the webAPI createRecord requests, and refresh() the dataset after that.
For that you need to declate the webAPI feature in the PCF manifest,
The datatset.refresh() will retrigger the updateView, and the changed dataset will be rendered.
Hope it helps!
WarrenBelz
85
Most Valuable Professional
Michael E. Gernaey
65
Super User 2025 Season 1
mmbr1606
55
Super User 2025 Season 1