Enhance Form Communication with Subgrid Dataset PCF
Image Source: Shutterstock.com
Model-Driven App
Sep 30, 2023 8:17 AM

Enhance Form Communication with Subgrid Dataset PCF

by HubSite 365 about Diana Birkelbach [MVP]

Dianamics PCF Lady | Microsoft MVP | Blogger | Power Platform Community Super User | 👩‍💻 Dynamics 365 & PowerPlatform Developer | ORBIS AG

Citizen DeveloperModel-Driven AppM365 Hot News

Master the art of dataset communication in Microsoft Model-Driven Apps! Discover the 100% supported solution to ensure consistent dataset behavior on your forms

Improving Dataset Power Component Factory (PCF) Interaction in Model-Driven Apps

In the latest blog by Diana Birkelbach, a Microsoft MVP, she discusses the communication between dataset PCFs in a subgrid and different aspects of the Model-Driven App form.

A change in the dataset PCF on a subgrid may affect other information displayed on these applications' forms. Previously, the usage of the Xrm object within a PCF was unsupported, meaning controls couldn't be accessed directly.

In instances when a field PCF was present, another property would have been included in the manifest and updated accordingly. However, a combination of a dataset and bound property is incompatible with these applications, leading to registration challenges.

A New Approach: Using Output Properties

While dataset and bound properties and their combination don't align well, a mix of dataset and output property works better. A property of type DateAndTime is used for the output property. Although events can't be raised from PCFs, the datetime property triggers an event OnOutputChange on the form each time it changes.

To give the output properties a data aspect, a value for open tasks is added to the event, ensuring the whole form isn't refreshed after each modification.

Documentation is Key

According to Birkelbach, it is necessary for the PCF to be comprehensively documented to aid in form scripting.

Distinguishing Changes in Record Count

Several actions can change the data inside a PCF. One efficient way to manage a record count is to look inside the PCF updateView method. If the totalRecordCount changes, an event can be raised.

This method provides a quick means to display the counter from available data, avoiding additional requests just to refresh the form or the counter control. Ultimately, these output properties allow the form to remain synchronous with all changes.

Read the full article Let Your Subgrid Dataset PCF Communicate with the Form

Model-Driven App - Enhance Form Communication with Subgrid Dataset PCF

Learn about Let Your Subgrid Dataset PCF Communicate with the Form

Understanding how Power Apps' components, such as subgrids and datasets, interact with Model-Driven Apps forms is essential for building custom solutions. The changes that occur within a dataset (like on subgrids) could affect other information shown on a form.

The Power Apps Component Framework (PCF) facilitates the creation of field or dataset components. Supported features, such as the output properties and API methods, provide reliable solutions for managing and utilizing datasets. For instance, dataset PCFs can trigger an event by updating the value of a particular property within the manifest.

However, there are limitations and discrepancies to be aware of—such as issues with registering a dataset and a bound property combination on a form, especially on Model-Driven Apps.

Previously, postMessage was an option, but it wasn't fully supported. This gave prominence to the output properties feature. APIs like getOutputs and addOnOutputChange are relatively new and can provide secure ways to handle your dataset.

The provided use case exemplifies how these APIs can be used to solve typical problems. For instance, a form might have a registered PCF for ToDos with a counter. When tasks are added, completed, or canceled, it should refresh the counter control and timeline.

To solve this, we can use a combination of datasets and output properties for the PCF manifest. Enabling a feature like this would not have been possible without the output properties and the relative APIs.

The use case features several output properties within its manifest. These output properties can be used to pass data, like values for open tasks counters, alongside the event. Hence, we would not need to refresh the entire form after every change.

The PCF and form scripts accompanying this use case provide valuable insights into how you can further customize and manipulate data based on your requirements. Furthermore, the output properties can pass even complex objects, like an entire JSON.

If you want more details or the complete code for the use case provided, please visit our Github repository.

Output properties also come with several advantages. For instance, we can provide the record count, which updates every time the dataset changes. This gives you a fast way to show the counter from the currently available data, without making another request to refresh the form or counter control.

Using the newfound abilities of output properties, you can keep your form in sync with all the changes made within the datasets.

If you're interested in learning more about this topic, you might consider training courses such as Microsoft's Power Apps Development training program or component framework courses. This will enable you to gain a deeper understanding of concepts like the PCF and utilize its capabilities to the fullest.

More links on about Let Your Subgrid Dataset PCF Communicate with the Form

Let Your Subgrid Dataset PCF Communicate with the Form
May 19, 2023 — It is possible to build a PCF having both dataset and bound properties, but on some point you cannot go on to register it on a form. Not a very ...
Subgrid Dataset PCF: Programmatically Extend Relations
Jul 7, 2022 — In this blog the story goes on with examples: let's talk about how to use the dataset “linking sdk” to make PCFs for subgrids containing ...
Let Your Subgrid Dataset PCF Communicate with the Form
May 20, 2023 — In her blog post, Diana Birkelbach outlines how to make a subgrid dataset Power Apps Component Framework (PCF) communicate with other components ...


Subgrid Dataset PCF, Form Communication, PCF Communication, Dataset Programming, Subgrid Data Communication, Dataset Form interaction, Programming Form Communication, PCF Subgrid Communication, Dataset PCF Message, Subgrid PCF Interface