MSBA-279 · Lesson 5 of 12 · 19 min

Domain review: extending the user experience

▶ Video coming soon A video version of this lesson is on the way.

Wiremu took the lead for this review, which suited both of them. He had built the athletics loans code app and most of the RoomCapacity component; Signe had written more form scripts than she could count but had deployed a code app only once, by watching. "I will explain code apps," Wiremu said, "and you explain why my form script from last month fired twice." Signe laughed. "Because you registered the handler in the form designer and in code. That one is on the exam too."

The second domain, Extend the user experience, is worth 25 to 30 percent and has four objective groups with 22 skills: client scripting in model-driven apps, PCF code components, building code apps and deploying and managing code apps. It was taught in Extending the User Experience (MSBA-271). This lesson reviews what the exam expects in each group and the facts most often tested.

Client scripting in model-driven apps

The client scripting group has five skills: build code that targets the Client API object model, determine an event handler registration approach, create client scripting that targets the Dataverse Web API, configure commands and buttons with Power Fx and JavaScript, and implement navigation, dialogs and notifications with the Client API.

The object model starts with the execution context. When a form event fires, the platform passes an execution context to the handler if the registration says to pass it. From it, the handler gets the formContext with executionContext.getFormContext(), and from the formContext it reaches data (attributes and their values) and UI (controls, tabs, sections and notifications). The global Xrm object provides utilities that do not belong to one form, such as Xrm.WebApi for data, Xrm.Navigation for opening forms and dialogs, and Xrm.Utility. The older Xrm.Page object is deprecated, and code questions use formContext.

NeedClient API member
Read or set a column valueformContext.getAttribute(name).getValue() / setValue()
React when a column changesAn OnChange handler, registered in the designer or with addOnChange
Show or hide a controlformContext.getControl(name).setVisible()
Show a message on one fieldcontrol.setNotification() and clearNotification()
Show a message at the top of the formformContext.ui.setFormNotification() and clearFormNotification()
Read or write other recordsXrm.WebApi.retrieveRecord, retrieveMultipleRecords, createRecord, updateRecord
Open a form, page or dialogXrm.Navigation.openForm, navigateTo, openAlertDialog, openConfirmDialog
Stop a saveexecutionContext.getEventArgs().preventDefault() in an OnSave handler

Handler registration is a skill in its own right. Handlers for OnLoad, OnSave and OnChange can be registered in the form designer, which is visible to anyone customizing the form, or in code with methods such as addOnChange and addOnSave, which is useful when a handler depends on runtime conditions. Registering the same function both ways makes it run twice. Some events, such as a lookup control's PreSearch, can only be registered in code. Asynchronous OnLoad and OnSave handlers are supported when enabled in the app settings, so a handler can return a promise and the platform waits for it, within a time limit.

Client scripts that call the Dataverse Web API normally use Xrm.WebApi, which handles authentication and returns promises. A question may show a call to retrieveMultipleRecords with an OData query string and ask what it returns, or which option gets only the columns needed. The answer is almost always the one that uses the select query option to limit columns and the filter option to limit rows, because performance is part of the skill.

Commands use modern commanding: buttons on the command bar defined in the command designer, with actions and visibility written in Power Fx or in JavaScript from a web resource. Power Fx suits simple actions and visibility rules expressed against the selected record; JavaScript suits logic that needs the full Client API or a custom dialog. A frequent question asks how to show a button only when a record meets a condition: a Power Fx visibility formula on the command, not a script that hides the button after load.

PCF code components

The PCF group has five skills: the lifecycle events, the manifest, component interfaces, packaging and deployment, and the Device, Utility and Web API features. A code component built with the Power Apps component framework is a TypeScript class that implements a standard interface. The platform calls its methods at defined moments.

The PCF component lifecycle. init runs once with context, notifyOutputChanged, state and container. updateView runs whenever data, size or mode changes. When the user changes a value, the component calls notifyOutputChanged, and the platform calls getOutputs to read the new value. destroy runs when the component is removed.
The four lifecycle methods of a code component and how they interact.
MethodCalled whenTypical work
initOnce, when the component is createdStore notifyOutputChanged; build the DOM in the container (standard controls); read initial parameters
updateViewWhenever a bound value, input, size or mode changesRender from context.parameters; for React (virtual) controls, return the element tree
getOutputsAfter the component calls notifyOutputChangedReturn the values for bound output properties
destroyWhen the component is removedRemove event listeners and release resources

The most common lifecycle question asks why a changed value does not reach the form. The component updated its internal state but never called notifyOutputChanged, so the platform never called getOutputs. A second common question asks where to render: in updateView, because it is called whenever data changes, not only once like init.

The manifest, ControlManifest.Input.xml, describes the component to the platform: its namespace, constructor and version; whether it is a field or dataset component; its properties with their usage (bound, input or output) and types or type groups; its resources (the code file, CSS and resx strings); and its feature usage. A component that uses the device camera, or the Web API, must declare it with uses-feature elements in the manifest. A component that calls external services must declare that too, and that makes apps that use it premium. The version in the manifest must increase when a new build is deployed, or the platform may keep the old one, which is the cause behind more than one "my change does not appear" question.

Manifest elementPurpose
control (namespace, constructor, version, control-type)Identity and type; control-type virtual means a React component using platform libraries
property (usage bound, input or output; of-type or type-group)Values the component reads from or writes to the host
data-setFor dataset components that show a set of records
resources (code, css, resx, platform-library)Files and shared libraries such as React and Fluent
feature-usage with uses-featureDeclares use of Device, Utility or WebAPI features

Packaging follows the CLI. pac pcf init creates the project with a namespace, name and template (field or dataset). npm run build compiles it, and npm start watch runs the local test harness. During development, pac pcf push deploys the component quickly to an environment using a publisher prefix. For release, the component goes into a solution: a solution project created with pac solution init references the component project, and building the solution project produces a solution zip that ALM can carry. A component reaches users when it is added to a form field, a view or a canvas app.

Building Power Apps code apps

The code apps groups are the largest new material in AB-400. A Power Apps code app is a web application written in a framework such as React with TypeScript and run as a Power Apps app. The developer writes the whole interface; the platform supplies Microsoft Entra sign-in, governed access to connectors and Dataverse through the Power Apps client library, sharing, licensing and policies such as data policies and Conditional Access. Code apps became generally available in February 2026.

A code app architecture. The developer's React and TypeScript code calls generated services. The services call the Power Apps client library, which runs inside the Power Apps host. The host handles sign-in and calls connectors, Dataverse tables, Dataverse actions and functions, cloud flows, Copilot Studio agents and environment variables. Around the host: Content Security Policy, data policies, Conditional Access, sharing and Application Insights.
How a code app reaches data and services through the Power Apps host.

The seven building skills follow what a code app can connect to: Power Platform connections, Dataverse tables, table and metadata operations, Dataverse actions and functions, Power Automate cloud flows, Copilot Studio agents and environment variables. Each is added to the project as a data source with the command-line tool, which generates TypeScript models and services. The app calls the generated service, the service calls the client library, and the library calls the platform with the signed-in user's identity. The developer never handles tokens.

SkillWhat the exam expects you to know
ConnectionsAdd a connector as a data source; users sign in to their own connections; data policies apply at run time
Dataverse tablesAdd tables as data sources; use generated services to create, retrieve, list, update and delete with select, filter, sort and paging options
Table and metadata operationsRead rows and table metadata such as choice labels; know the documented limits of generated services
Actions and functionsCall Dataverse custom APIs and other messages from the app
Cloud flowsAdd a flow as a data source and start it from the app
Copilot Studio agentsCall an agent from the app as a data source
Environment variablesRead settings that differ between environments without a new build

The command-line tooling changed during 2026. Microsoft's current guidance uses the Power Apps CLI in the npm package @microsoft/power-apps, with commands beginning pa, such as pa app init, pa app add data-source, pa app run and pa app push. The older pac code commands in the Power Platform CLI still work but are marked preview and due to be deprecated. Expect questions to describe what a step does rather than test exact command options, and check the current reference when you practise.

Code apps have prerequisites and limits that make good exam questions. An administrator must enable code apps for the environment. Users need a licence that covers premium features, because code apps are treated as premium apps. The documentation lists features code apps do not support, including Power Platform Git integration, SharePoint forms integration and use inside Power Apps for Windows. Generated Dataverse services also have documented limits, such as polymorphic lookups, FetchXML and alternate keys. A scenario that requires one of those is steering you away from a code app or towards another approach for that part.

Deploying and managing code apps

The deployment group has five skills: configure Content Security Policy, monitor with Azure Application Insights, package, deploy and share, troubleshoot with Monitor and browser tools, and optimize performance and resource usage.

SkillKey facts
Content Security PolicyEnforced by default for code apps; administrators adjust directives per environment in the admin center, for example to allow an external image or font host; prefer bundling assets over widening the policy
Application InsightsInstrument the app so page views, errors and dependencies reach an Application Insights resource; correlate with platform telemetry
Package, deploy and shareBuild the app, push it to the environment, add it to a solution for ALM, share with users or security groups like other apps
TroubleshootUse Monitor for platform calls and the browser developer tools for script errors, network calls and CSP violations
OptimizeRequest only needed columns and rows, page large lists, cache stable lookups, keep bundles small, avoid repeated calls on render

The CSP question pattern is predictable. A code app works locally but an image or script from an external host fails to load after deployment, and the browser console shows a policy violation. The answer is to adjust the environment's CSP setting for code apps to allow that source, or better, to bundle the asset with the app. Turning off CSP enforcement entirely is the distractor. The athletics loans app kept CSP at its defaults by bundling its fonts and reaching the weather banner through a custom connector rather than calling an external host directly from the browser.

Worked problem

Choosing between a PCF component and a code app

The facilities team wants a floor plan control on the work order form so dispatchers can choose a room by clicking it. A separate request asks for a standalone kiosk app at the gym counter, styled exactly like the athletics website, used by staff on a tablet. Which approach fits each request?

Show solution
  1. The floor plan is one control inside an existing model-driven form: a PCF field component bound to the room lookup.
  2. The kiosk is a whole app with a fully custom interface owned by developers: a code app.
  3. A generative page would not give exact branding; a canvas app could work but would not reuse the website's React components.

Answer: A PCF code component for the floor plan, and a Power Apps code app for the kiosk. This is the same split Lumenvale made with RoomPicker and the athletics loans app.

Common mistakes

  • MistakeUsing Xrm.Page in new form scripts.

    InsteadGet formContext from the execution context passed to the handler.

  • MistakeRegistering a handler in the designer and again in code.

    InsteadRegister once; double registration runs the handler twice.

  • MistakeChanging a PCF value without calling notifyOutputChanged.

    InsteadCall notifyOutputChanged so the platform calls getOutputs.

  • MistakeDisabling CSP to fix a blocked resource in a code app.

    InsteadBundle the resource or allow its source in the environment's CSP settings.

Summary and key terms

  • Domain 2 is worth 25 to 30 percent; 12 of its 22 skills are about code apps.
  • Client scripts use formContext from the execution context, Xrm.WebApi for data and Xrm.Navigation for forms and dialogs.
  • PCF components implement init, updateView, getOutputs and destroy; the manifest declares properties, resources and features.
  • Code apps reach connectors, Dataverse, flows, agents and environment variables through generated services and the Power Apps host.
  • Deploying code apps involves CSP, Application Insights, sharing, Monitor and performance tuning.
formContext
The Client API object for the current form, obtained from the execution context.
Execution context
The object the platform passes to a form event handler, giving access to the form and event.
Code component
A control built with the Power Apps component framework in TypeScript.
notifyOutputChanged
The callback a code component calls to tell the platform its outputs changed.
Power Apps code app
A web app written in a framework such as React that runs as a Power Apps app.
Content Security Policy
A browser security policy limiting which sources a page can load; enforced for code apps.
Modern commanding
The command designer for model-driven app buttons, using Power Fx or JavaScript.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Which PCF method should render the component when data changes?

    Show answer

    updateView.

  2. How should a command button be shown only for active records?

    Show answer

    With a Power Fx visibility formula on the command.

  3. What must an administrator do before developers can push a code app to an environment?

    Show answer

    Enable code apps for that environment.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz