PL 400 PCF Controls (Power Apps Component Framework) 2 — Questions and Answers
Question 1: In the `updateView` method signature, which parameter provides access to the control's current input property values and all framework services?
- context (Correct answer)
- inputs
- props
- state
Correct answer: context
The `context` parameter of type `ComponentFramework.Context<IInputs>` exposes `context.parameters` for property values plus all framework service APIs such as webAPI, formatting, and client.
Question 2: How does a PCF control signal to the host application that an output property value has changed?
- By calling context.events.notifyOutputChanged() (Correct answer)
- By directly mutating the context.parameters object
- By dispatching a CustomEvent on the control's container element
- By calling context.webAPI.updateRecord() with the new value
Correct answer: By calling context.events.notifyOutputChanged()
Calling `context.events.notifyOutputChanged()` tells the framework that output values have changed; the framework then calls `getOutputs()` to retrieve the new values and propagates them to the host.
Question 3: What is the purpose of the `getOutputs` method in a PCF control?
- To return a snapshot of all current output property values to the framework after notifyOutputChanged is called (Correct answer)
- To initialize the control's output DOM container elements
- To validate user input before persisting it to Dataverse
- To register handlers for data output events
Correct answer: To return a snapshot of all current output property values to the framework after notifyOutputChanged is called
`getOutputs` is called by the framework in response to `notifyOutputChanged()` and must return an object whose keys match the output properties defined in the manifest.
Question 4: Which ControlManifest.Input.xml element declares each bindable property, its data type, and its usage direction?
- <property> (Correct answer)
- <field>
- <parameter>
- <attribute>
Correct answer: <property>
The `<property>` element in ControlManifest.Input.xml defines each control property with attributes such as name, of-type, usage (bound/input), and required.
Question 5: What is the key architectural difference between a 'field' type and a 'dataset' type PCF component?
- Field components bind to a single scalar value; dataset components bind to a collection of records with columns (Correct answer)
- Field components use TypeScript; dataset components must use plain JavaScript
- Field components only work in canvas apps; dataset components only work in model-driven apps
- Field components support offline scenarios; dataset components require an active Dataverse connection
Correct answer: Field components bind to a single scalar value; dataset components bind to a collection of records with columns
Field-type controls replace a single-field control (e.g., a text box), while dataset-type controls replace multi-record views like grids or galleries, receiving a full dataset with multiple rows and columns.
Question 6: What should a developer implement in the `destroy` method of a PCF control?
- Cleanup of event listeners, timers, and external subscriptions to prevent memory leaks (Correct answer)
- Deletion of the associated Dataverse record when the form closes
- Deregistration of the control from the PCF global registry
- Resetting all property values to their manifest-defined defaults
Correct answer: Cleanup of event listeners, timers, and external subscriptions to prevent memory leaks
The `destroy` method is called when the control is removed from the UI and is the correct place to teardown event listeners, cancel pending async operations, and free any external resources.
Question 7: Which workflow correctly packages and deploys a PCF control to a Dataverse environment for production use?
- Build the solution with `pac solution build` to create an importable .zip, then import it via the Maker Portal or pac solution import (Correct answer)
- Upload the TypeScript source files directly through the Power Apps Maker Portal
- Run `npm run build --deploy` which automatically publishes to the connected environment
- Compress the project folder manually and upload it to Power Platform Admin Center
Correct answer: Build the solution with `pac solution build` to create an importable .zip, then import it via the Maker Portal or pac solution import
For production, `pac solution build` (or `msbuild`) creates a solution .zip that is imported like any other Dataverse solution; `pac pcf push` is a faster shortcut only appropriate for development environments.
In the `updateView` method signature, which parameter provides access to the control's current input property values and all framework services?