It's time to add some finishing touches to your PCF controls!

It is wonderful to see so many PCF controls being built by the community.  This post is a call-to-action for all PCF builders - it's time to make sure your PCF component handles read-only and field-level security! The good news is that it's really easy to do. There isn't much in the documentation about this subject, so I hope this will be of help.

Read-only or Masked?

In your index.ts, you first need to determine if your control should be read-only or masked. It will be read-only if the whole form is read-only or the control is marked as read-only in the form properties. It can also be read-only if Field Level Security is enabled. Masked fields are where the user doesn't have access to read the field due to the Field Security Profile settings. Typically masked fields are shown as *****.

// If the form is diabled because it is inactive or the user doesn't have access
// isControlDisabled is set to true
let readOnly = this._context.mode.isControlDisabled;
// When a field has FLS enabled, the security property on the attribute parameter is set
let masked = false;
if ( {
  readOnly = readOnly || !;
  masked = !;

Pass the flags to your control

I use React for my control development and so this makes it really easy to pass the details into the component. You'll then need to ensure your control is disabled or masked when instructed to.

  React.createElement(PicklistControl, {
    value: this._selectedValue,
    options: options,
    readonly: readOnly,
    masked: masked,
    onChange: this.onChange,


Testing the result!

Here I have a simple picklist PCF control. It is associated with two Optionset fields. One normal, and one with Field Level Security:

The 'Secured Optionset' field is masked because the associated Field Security Profile has 'No' on the 'Read' setting. This causes the readable property to be false.

If we toggle this to 'Yes' the field will be readable, but not editable because 'Update' is set to 'No':

If we then set Update to 'Yes' we can then edit both fields:

Finally, let's deactivate the whole record. This will then show both fields as read-only - irrespective of the Field Security!

You can see that the record is read-only by the banner at the top of the record:

Call to action!

If you have any PCF controls out there, it's time to re-visit them and check they handle read-only and Field Level Security settings.


Comments are closed