Study FAQ
How should a PCF component use Device, Utility and Web API capabilities?
Also asked as 2
- How do I declare PCF features and handle hosts that lack them?
- How can a PCF control use camera, metadata or Dataverse reads while handling unavailable capabilities?
Answer
Check the intended app and client for each PCF method. Declare the feature in manifest feature-usage, mark it required only when the control cannot operate without it, and give optional capabilities a fallback.
- Device. For optional mobile image capture, declare
Device.captureImagewithrequired="false". Check availability, launch capture after a user action, and handle cancellation or permission denial. Test the fallback on an unsupported client. - Utility. In a supported model-driven host, use
context.utilsfor features such as metadata or lookup dialogs. WhenhasEntityPrivilegedepends on uncached metadata, retrieve the metadata first. Treat the result as a table-level hint and handle the actual row operation's outcome. - Web API. In a supported host, declare
WebAPIand usecontext.webAPIfor a bounded read, for example retrieving only the account name. Capture the input identifier before the call and discard responses that no longer match the current request or arrive after disposal. Distinguish a failed read from a missing display value.
Test with the intended user's role and supported client. Include a denied permission, a host without the optional feature and an input change during a pending request.
PCF feature-usage manifest example · Optional and required PCF features · Camera capture · Privilege API · PCF retrieveRecord
Full explanation
AB-400: Building Reusable PCF Code Components
Study guide · AB-400
Read the full explanation