Hi everyone, we have a dataset PCF control that needs to read a "totalCost" amount from a form, and update "totalAllocated" and "totalUnallocated" fields on the form. I'm trying to do this with bound properties, but the dataset control is not available (doesn't show up in CRM) as an option for the form's subgrid unless I change the bound parameters to input parameters. If I do that, then only the initial field values from the form are passed in, and the PCF cannot update them...and changes to the "totalCost" field are not picked up by the PCF.
Do bound properties not work properly with dataset controls, or am I doing something wrong?
<manifest>
<control namespace="capsITK" constructor="ExpenditureAllocationGrid" version="0.0.41" display-name-key="ExpenditureAllocationGrid" description-key="ExpenditureAllocationGrid description" control-type="standard">
<data-set name="ExpenditureAllocationDataSet" display-name-key="Dataset_Display_Key">
</data-set>
<property name="totalCost" display-name-key="Total Cost" description-key="The field that holds the total allocatable cost" of-type="Decimal" usage="bound" required="true" />
<property name="totalAllocated" display-name-key="Total Allocated" description-key="The field that holds the calculated allocatable cost" of-type="Decimal" usage="bound" required="true" />
<property name="totalUnallocated" display-name-key="Total Unallocated" description-key="The field that holds the calculated unallocatable cost" of-type="Decimal" usage="bound" required="true" />
<property name="yearlyExpenditureFieldName" display-name-key="Yearly Expenditure Field Name" description-key="The name of the field that holds the yearly expenditure amounts" of-type="SingleLine.Text" usage="input" required="false" />
<property name="lockOnInactiveState" display-name-key="Lock on Inactive State" description-key="Lock the control if the state field is inactive true or false" of-type="SingleLine.Text" usage="input" required="false" />
<resources>
<code path="index.ts" order="1"/>
<css path="css/ExpenditureAllocationGrid.css" order="2" />
<resx path="strings/ExpenditureAllocationGrid.1033.resx" version="1.0.0" />
</resources>
<feature-usage>
<uses-feature name="WebAPI" required="true" />
</feature-usage>
</control>
</manifest>
Hi @mikemcg ,
Maybe making 2 PCFs : one dataset and one field, and using postMessage might help too: https://dianabirkelbach.wordpress.com/2020/05/15/can-pcfs-communicate/
Best regards,
Diana
Sure, but we can code for having form context/bound form fields or not. If my dataset control is only meant to work on a form, I can simply render a message if someone tries to use it in a main grid.
@mikemcg one problem is that a Dataset PCF component does not need to be used on a subgrid within a form it can also be used to replace the grid on the entity /home list page in which case no form would exist.
Hi @mikemcg
I totally agree. It's clumsy in Model-Driven Apps. And if I think about the CanvasApps it's even worse, since we cannot use webAPI there and we don't know what DataSource-Type was used.
I still hope I'm missing something, or that there will open a possibility to change the data in a DataSet directly. ::dreaming:: 🤔
Best regards,
Diana
Thanks @ben-thompson, yes, I used the WebAPI to save changes to my subgrid records, and also to save the totals back to the parent record. It all works, but would be much cleaner if MS adds support for form-bound properties for a dataset PCF control. The issue with all of this is that the form is unaware of the changes to the total fields unless I force-refresh the PCF, detect that event on the form, and then re-load the form data. Clunky!
Thanks for all of your input, at least we have a working solution for now 🙂
It's probably obvious but don't forget that after hiding the Total / Allocated / Unallocated fields on the form you can use the Webapi to update the core record in the background. The link was open so you can find it at https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/webapi/updaterecord but you will need to enable the WebApi feature (I mention that as I've forgotten to do that more than once in the past).
Ahh, thanks @ScottDurow and @ben-thompson, I wasn't understanding Ben's suggestion correctly, but yes, that could work. But it becomes a bit more difficult to build it generically when it's not connected straight to a specific view. I think we're going to stick with a dataset for now, and display the Total/Allocated/Unallocated fields within the PCF. If we end up needing form logic around Total/Allocated/Unallocated, I'll have to trigger the grid load event from the PCF, and pick that up on the form.
I think @ben-thompson is on the right track - using a field PCF to render the grid would probably make the most sense because you are then entirely inside the form context and can update the form fields accordingly.
Hi @ScottDurow, about all I can seem to do is force the PCF dataset to refresh, catch the grid onLoad event on the form, and then force the form data to refresh. Is this the best that can be done, or do you see any other options for passing data updates from dataset PCF to form without having to force-refresh both?
...at least in terms of supported approaches 😉
@ben-thompson Thank you for clarifying.
My comment was in context of my previous comment about dataset and field components not being able to communicate between each other using the PCF api. Certainly bound fields can be shared between components and so they can share the same data - but dataset can’t raise an event in a field component which is what this question seems to be about. I dare say there are plenty of non-API approaches that could be used which may by somewhat unsupported!
WarrenBelz
55
Most Valuable Professional
mmbr1606
44
Super User 2025 Season 1
Michael E. Gernaey
31
Super User 2025 Season 1