The page scripting tool in the Business Central web client lets you record your actions, such as opening pages or entering data, and replay them. You can save the recording and share it with others for future playback. An important use case for the tool is capturing and running user acceptance tests. This use case is the initial focus for this release wave.
In the web client, you access the page scripting tool from the Settings menu (cog wheel icon). The Page Scripting action appears only if you have record or playback permission to use the tool.
![Choose Page Scripting in the Settings menu to open it Choose Page Scripting in the Settings menu to open it]()
The Page Scripting pane opens on the right. You can start a new recording or open an existing recording to inspect or replay.
![When opening Page Scripting, you can start a new recording or open an existing one to play back When opening Page Scripting, you can start a new recording or open an existing one to play back]()
Record
To record your actions and start a user acceptance test, select Start new or select New > New recording in the toolbar at the top of the pane. When recording starts, the toolbar shows a solid red circle. Perform the actions you want to capture.
The page scripting tool captures your on-screen interactions and the resulting actions. It captures actions such as opening or closing pages, selections, and data entry.
During recording, you can delete the last captured step.
To stop the recording, use the Stop button in the toolbar. To resume recording and add more steps, select the round Start recording button in the toolbar.
The following image shows some captured steps and the toolbar while recording.
![Example of recording steps Example of recording steps]()
Options for capturing steps
During recording, you can add special steps by right-clicking a page control, such as a field, and selecting an option. The following sections explain these options.
Copy to and paste from clipboard
The page scripting tool includes a clipboard that you can use to copy field values. For example, you can insert copied values into other fields, use them in expressions, or use them to validate results. To copy and paste during recording, right-click a page control, and select Copy or Paste from the context menu.
![Example of pasting value copied to clipboard Example of pasting value copied to clipboard]()
Paste session info
When you record, you can access session information, such as the user ID. With this information, you can set filters based on the current user. To insert the user ID, right-click a control in the page and select Paste > Session Info > User ID. For an example, see the preceding image.
Validate an outcome
During recording, insert validation steps to check the outcome when you play back the recording. Right-click a control, such as a field or cue, and select Validate in the context menu. This step inserts a validation step with the current value. To change the value that the step validates, go to the validate step in the Page Scripting step list, select the context menu ..., and select Properties.
![Insert a validation step during recording Insert a validation step during recording]()
Make steps conditional
During recording, you can insert a conditional branch step. For example, you might want to perform some steps during playback only if there are no current rows in a list.
To insert a branch of conditional steps, right-click a page control, select Add conditional steps when, and then select an option.
When you insert the conditional step, you can add more steps to perform when the condition is met.
To end the conditional branch, select End scope in the Page Scripting steps list.
To change the condition, select the condition step in the Page Scripting step list. Expand the properties, and set the comparison rule and value.
![Modify comparison rule and value for compare step Modify comparison rule and value for compare step]()
Edit captured steps
During recording and playback, you can edit a captured step in the Page Scripting pane by using the context menu ... on the step. The options in the context menu depend on whether you're in record or playback mode and the kind of step. Some of the options are described in the following sections.
Properties
Some steps have properties that include conditional steps or validation steps. Select Properties from the context menu on a step to see the properties for a step.
![Example of step value set with a Power Fx expression Example of step value set with a Power Fx expression]()
Using expressions in properties
Values and conditions can use expressions for simple calculations. Power Fx is the expression language. The UI provides a link to the Power Fx expression reference documentation.
Besides the Power Fx functions, three top-level objects are available:
Clipboard
for access to the current entries you copied in the recording. Parameters
for access to the value of any parameters you pass to the recording. SessionInfo
for session information like the current user ID.
Here are a couple of examples:
- To validate that a previously copied value is incremented in a validate step, use the expression
Clipboard.'SO Processor Activities - ReadyToShip' + 1
. - To generate a "random" name to use in an input step, use the expression
Customer " & Today()
.
Handle optional pages
Sometimes a recorded flow doesn't show a page because the page depends on data or settings. For example, the page might be the confirm dialog that appears when you close a sales order. To handle this situation, make the page an optional page. The flow runs the steps under the page only if the page appears. To make a page optional, go to the Page Scripting step list, select the recorded step named Page X was shown, select the context menu ..., and select Make this an optional page.
![How to make a page optional How to make a page optional]()
The steps that occur on the page are indented to show that they're optional steps. The steps run only if the page appears.
![Once a page is optional, the steps for that page appear nested under the page Once a page is optional, the steps for that page appear nested under the page]()
Playback
Select Play in the toolbar to play a recording you captured or opened from a file.
During playback, you can:
- Go forward or backward a single step by using Forward and Backward buttons in the toolbar. When you step backward, the tool doesn't undo changes. You need to undo changes manually.
- Go back to the beginning of the recording.
- Run the recording as far as a given step. Select the context menu ..., and then select Run to here.
As the tool plays back the steps, it records whether each step completes successfully (green check mark) or fails (red exclamation mark). The tool shows the result for any steps that validate a result.
![Result of playing back a recording. Includes result of each step. Result of playing back a recording. Includes result of each step.]()
Save a recording
Select Save in the toolbar to save the recording. This action creates a YAML file that you can download, share, edit, and reopen for playback.
Share a recording
Select Share in the toolbar to share a recording as a link. The link includes the full recording and its playback result. In the following example, the playback fails halfway through the recording.
![Share a recording along with the replay result Share a recording along with the replay result]()
Supported capture actions
The page scripting tool captures actions from running AL code. The tool isn't a general HTML automation tool. It can't automate elements such as control add-ins (like charts), embedded Power BI or Power Apps, or anything outside the Business Central web client experience.