Creating Macros in Business Central with Page Scripting
- John Ellis
- Aug 26
- 2 min read
Updated: Sep 4
Last September we published a blog article on Business Central’s Page Scripting -- a feature which records events such as opening pages, entering data in fields, and selecting actions.
Conventionally, these recordings are used to review the results of User Acceptance Testing.
We at Turnkey Technologies have discovered another use for this feature – creating macros!
Please follow this guide to learn how to create macros in Microsoft Dynamics 365 Business Central using Page Scripting.
Steps to Creating Macros in Business Central with Page Scripting
Recording
Click the “Settings” button found in the top right-hand corner of Business Central, to open Page Scripting:


After clicking the “Start new” button shown above, click the red dot to begin recording:

For this recording, you can open and close a Sales Quote.
Once you have concluded recording, click the “Stop” button.
Saving the Recording
Click the ellipsis button at the top of Page Scripting, to save the test as a “YAML” file:

As a refresher from the previous article, “YAML” is a data interchange file and more information may be found at yaml.org.
Replaying
To replay these steps and determine if testing was successful, click the “Play” button:

In clicking Play, the Sales Quote will reopen and reclose.
Editing the Recording
Opening and editing this YAML file in Notepad will, in essence, program Business Central to conduct other operations besides opening and closing a Sales Quote!
For example, what if you want to create a Sales Order instead of a Sales Quote?
It’s simply a matter of editing the file!
Transforming the Recording into a Macro
Here is the YAML file, as opened in Notepad:
name: Recording
description: Test recording
start:
profile: BUSINESS MANAGER
steps:
- type: invoke
target:
- page: Business Manager Role Center
runtimeRef: b0
- action: Sales Quote
description: Invoke <caption>Sales Quote</caption>
- type: page-shown
source:
page: Sales Quote
modal: false
runtimeId: bb6c
description: Page <caption>New - Sales Quote</caption> was shown.
- type: focus
target:
- page: Sales Quote
runtimeRef: bb6c
- field: Sell-to Customer Name
description: Focus <caption>Customer Name</caption>
- type: close-page
target:
- page: Sales Quote
runtimeRef: bb6c
description: Close page <caption>New - Sales Quote</caption>
- type: page-closed
source:
page: Sales Quote
runtimeId: bb6c
description: Page <caption>New - Sales Quote</caption> was closed.
Within this file, conduct a find on “Quote” and replace with “Order”.
Once the file is saved with this change, browse out to the file:

Pressing the “Play” button creates a new Sales Order in Business Central.
The “before” and “after” screenshots, shown on the next page, prove this.
before

after

S-ORD101048 is a new Sales Order created by this macro!
Security and Other Considerations
To record, your user account must have the “PAGESCRIPTING – REC” permission set or equivalent permissions.
To play a recording, your user account must have the “PAGESCRIPTING – PLAY” permission set or equivalent permissions.
(Testing of the new “Page Scripting” feature for this blog article was conducted in application version 26.3.36158.37931.)
For help or support, please feel free to contact us.