Tips for building your first PCF Control

Zoe Sands, 28 May 2020

I have been playing around with PCF Controls in Dynamics 365 and have some tips for anyone wanting to dive in and give it a go. There are some great resources online which really helped which I have linked below.

How to create a PowerApps PCF control

PCF Control Guide

While following the instructions in the guide, I ran into some strange errors when working with parameters.

Type ‘string | null’ is not assignable to type ‘string’. Type ‘null’ is not assignable to type ‘string’.

image

The fix for this is to make sure you have a default value for the value you’re trying to get. In this case, I had to default to empty string.

image

The following methods could be confusing as one is often called but not well documented (notifyOutputChanged) and the other appears to be never called (getOutputs).

In the getOutputs method you should be looking to set any of the bound fields from your ControlManifest. As shown below. When you call the notifyOutputChanged method it will call the getOutputs method and set any of the bound values you have set in there.

image

image

I hope this helps you if you are looking for reasons you are getting errors in your PCF control.