Page Scripting records what you do in the Business Central web client, such as opening pages, filling in fields, and selecting actions, and replays it later. As the recording plays, each step is marked as passed or failed. It reached general availability in version 29.0 (2026 release wave 2), after several releases in preview.
The main use is user acceptance testing. Record the processes that matter, such as creating and posting a sales order or running a payment journal, and replay them in a sandbox before each major update. Consultants also use recordings to show a customer a process step by step, or to document a bug in a form a developer can reproduce.
When to Use This
- Before a major update, to confirm that key processes still work in a sandbox on the new version.
- After installing or updating an extension that touches sales, purchasing, or posting.
- To hand a reproducible bug report to a partner or developer.
- As part of a build pipeline, together with AL unit tests.
Page Scripting tests the UI and the AL code behind it. It doesn’t automate control add-ins, embedded Power BI reports, or anything outside the web client.
Prerequisites
| Task | Permission set |
|---|---|
| Record | PAGESCRIPTING - REC |
| Play back | PAGESCRIPTING - PLAY |
Page Scripting works in every environment type: online production and sandbox, on-premises, and containers. Run your tests in a sandbox, though. A recording posts real documents.
Step 1: Open Page Scripting
- Go to the page where your process starts. The Role Center is usually the best starting point, because playback always starts from the current page.
- Select Settings (the cog icon) > Page Scripting.
The Page Scripting pane opens on the right.
Step 2: Record a Process
- Select Start new. The record button turns red.
- Go through the process as you normally would. For example: open Sales Orders, select New, choose a customer, add a line, and select Post.
- Each action appears as a step in the pane.
- Select Stop when you are done.
While recording, you can:
- Pause with Stop and continue with Start recording.
- Delete a step with … > Delete.
- Drag steps to reorder them.
- Insert steps between existing ones with … > Record from here on the step before.
Step 3: Add Validations
A recording that only clicks through a process proves that nothing crashed. Validations prove that the result is right.
- Right-click the field you want to check, for example Amount Including VAT on the posted invoice.
- Select Page Scripting > Validate > Current value.
- Select Is [current value].
A validation step is added. To change the expected value or operator later, select … > Properties on the step and edit Operator and Value.
You can also validate the text in a message or error dialog, the row count of a list, or the number of selected rows in a fully loaded list.
Step 4: Handle Variations
Real data doesn’t always behave the same way twice. Three tools help:
Conditional steps. Right-click a control and select Page Scripting > Add conditional steps when, then pick a condition, for example Row count > is 0. Record the steps that should only run when the condition is true, then select End scope.
Optional pages. Confirmation dialogs sometimes appear and sometimes don’t. On a step like Page X was shown, select … > Make this an optional page. The following steps only run if the page appears.
Repeat per row. Right-click a control in a list and select Page Scripting > For each. Record the steps to repeat, then select End scope.
Step 5: Use Parameters and Expressions
Hard-coded values make recordings fragile. A customer number that exists in one sandbox may be missing in the next.
- In the control bar, select … > Properties.
- Under Parameters, select + Add parameter and fill in Name, Type, Default value, and Description.
- On the step that uses it, open … > Properties and enter
Parameters.'Customer No.'as the value.
If a parameter has no value at playback, Page Scripting asks for one.
Property values are Power Fx expressions, so you can calculate values:
| Expression | Use |
|---|---|
"Customer " & Today() |
Create a unique name for a new customer |
Clipboard.'SO Processor Activities - ReadyToShip' + 1 |
Check that a cue went up by one |
Session.'User ID' |
Filter a list on the current user |
The clipboard values come from right-clicking a control and selecting Page Scripting > Copy during recording.
Step 6: Save, Share, and Replay
- Save downloads the recording as a YAML file. Add a description first with … in the Recording bar.
- Share > Copy Link creates a link that includes the recording and the results of the last playback.
- Open in the pane loads a saved file. Select Play to run it.
During playback, a green check marks a passed step and a red exclamation mark a failed one. Use Previous, Next, Rewind, or … > Run to here to move through the steps. Going back doesn’t undo what a step already did.
Step 7: Build a Test Suite
Split long processes into small recordings and combine them:
| Recording | Does |
|---|---|
01-create-customer.yml |
Creates a customer with a unique name |
02-create-sales-order.yml |
Creates an order for that customer |
03-post-sales-order.yml |
Posts the order and validates the totals |
In a host recording, select a step and use … > Add Step > Include a script to pull in the others. Define the same parameters in the host and the included scripts to pass values between them, such as the new customer number.
Step 8: Run Recordings in a Pipeline
The bc-replay npm package plays recordings outside the browser, which lets you run them in a build pipeline. It needs Node.js 16.14 or later and PowerShell 7.
mkdir c:\bc-replay
cd c:\bc-replay
npm i @microsoft/bc-replay --save
Run all recordings in a folder against a web client:
npx replay .\recordings\*.yml `
-StartAddress https://businesscentral.dynamics.com/{tenantId}/Sandbox/ `
-Authentication AAD `
-UserNameKey BC_TEST_USER `
-PasswordKey BC_TEST_PASSWORD `
-ResultDir c:\bc-replay\results
-UserNameKey and -PasswordKey name environment variables that hold the credentials. The test account can’t use multifactor authentication. View the results with:
npx playwright show-report c:\bc-replay\results\playwright-report
Tips
- Create the data a test needs inside the test. A recording that depends on customer 10000 existing breaks the first time someone deletes it.
- Filter lists so the record you want appears first before you select it.
- Keep a set of recordings per customer for the processes they sign off on during go-live, and replay them in a sandbox before each major update.
To set up the sandbox where you run these recordings, see How to Use the Business Central Sandbox Environment for Development.