Microsoft hat mehrere Verbesserungen am Business Central Migration Voucher Program angekündigt, darunter eine Ausweitung der Teilnahmeberechtigung und eine Erhöhung der ...
WeiterlesenParameterizing Page Scripting Tool Scripts in Microsoft Dynamics Business Central
Thursday, July 11, 2024
Reading time: 7 minutes
In the world of Microsoft Dynamics Business Central, efficiency and flexibility are key. One way to achieve this is by parameterizing your page scripts. This approach allows you to modify and reuse scripts easily without the need to change multiple instances of a specific value within the script. This BLOG is based on the preview version of the page scripting tool, version 24, so this BLOG post may very well not remain relevant in future versions, but for now, it works. So today, we’ll explore how to parameterize your scripts using a practical example.
What Does It Mean to Parameterize a Script?
Example: Parameterizing a Customer Filter Script
Let’s take a script that opens the list of customers, filters to customer 10000, opens the customer card, and validates that the correct customer has opened. We’ll then transform it into a parameterized script where the customer number is a parameter.
Original Script
name: Cust10000
description: Test recording
start:
profile: BUSINESS MANAGER EVALUATION
steps:
- type: navigate
target:
- page: Business Manager Role Center
- action: Customers
description: Navigate to <caption>Customers</caption>
- type: page-shown
source:
page: Customer List
modal: false
runtimeId: b4r3
description: Page <caption>Customers</caption> was shown.
- type: filter
target:
- page: Customer List
runtimeRef: b4r3
operation: add
column:
field: No.
scope: filter
description: Add filter for <caption>No.</caption> on <caption>Customers</caption>
- type: input
target:
- page: Customer List
runtimeRef: b4r3
- scope: filter
field: No.
value: "10000"
description: Input <value>10000</value> into <caption>No.</caption>
- type: invoke
target:
- page: Customer List
runtimeRef: b4r3
- repeater: Control1
invokeType: Edit
description: Invoke row on <caption>Control1</caption>
- type: page-shown
source:
page: Customer Card
modal: false
runtimeId: b5d1
description: Page <caption>Customer Card</caption> was shown.
- type: validate
target:
- page: Customer Card
runtimeRef: b5d1
- field: No.
operation: =
value: "10000"
description: Validate <caption>No.</caption> <operation>is</operation>
<value>10000</value>
Parameterized Script
Now, let’s parameterize the customer number in this script:
name: Cust10000
description: Test recording
parameters:
CustomerNo:
type: string
default: "20000"
start:
profile: BUSINESS MANAGER EVALUATION
steps:
- type: navigate
target:
- page: Business Manager Role Center
- action: Customers
description: Navigate to <caption>Customers</caption>
- type: page-shown
source:
page: Customer List
modal: false
runtimeId: b4r3
description: Page <caption>Customers</caption> was shown.
- type: filter
target:
- page: Customer List
runtimeRef: b4r3
operation: add
column:
field: No.
scope: filter
description: Add filter for <caption>No.</caption> on <caption>Customers</caption>
- type: input
target:
- page: Customer List
runtimeRef: b4r3
- scope: filter
field: No.
value: =Parameters.'CustomerNo'
description: Input <value>=Parameters.'CustomerNo'</value> into <caption>No.</caption>
- type: invoke
target:
- page: Customer List
runtimeRef: b4r3
- repeater: Control1
invokeType: Edit
description: Invoke row on <caption>Control1</caption>
- type: page-shown
source:
page: Customer Card
modal: false
runtimeId: b5d1
description: Page <caption>Customer Card</caption> was shown.
- type: validate
target:
- page: Customer Card
runtimeRef: b5d1
- field: No.
operation: =
value: =Parameters.'CustomerNo'
description: Validate <caption>No.</caption> <operation>is</operation>
<value>=Parameters.'CustomerNo'</value>
Step-by-Step Guide to Parameterize Your Script
- Record the Script: Use Business Central’s new Page Scripting Tool to capture or record the actions you want to automate.
- Export the Script: Once recorded, export the script to a YAML file.
- Add Parameters: Define your parameters at the top of the YAML file under the parameters section. In our example, we defined CustomerNo with a default value of “20000”.
- Replace Hardcoded Values: Replace the hardcoded values in the script with the parameter reference. For instance, replace value: “10000” with value: =Parameters.’CustomerNo’.
- Import the Script: Import the parameterized script back into Business Central.
- Run the Script: Now, when you run the script, you can specify different customer numbers without modifying the script itself.
Benefits of Parameterizing Your Scripts
- Efficiency: Update values in one place without searching through the entire script.
- Flexibility: Easily reuse scripts for different scenarios by changing parameter values.
- Maintainability: Simplify script maintenance and reduce errors by minimizing hardcoded values.
Conclusion and Disclaimer
As mentioned in the beginning, this is based on version 24 of Business Central, and the Page Scripting Tool is still in Preview, which means that features may very well change in future, or Microsoft may make it easier for us to achieve the same result. For now this is how the page scripting tool is working. Give your feedback if you would like to see features in this tool and help shape the future of this tool. Be careful not to invest too heavily into developing scripts for this tool until the tool is in it’s final release, happy scripting.
Parameterizing your scripts in Microsoft Dynamics Business Central is a powerful technique to enhance your automation workflows. By following the steps outlined above, you can create flexible, maintainable scripts that save you time and effort. Start parameterizing your scripts today and experience the benefits of a more streamlined process!
Meet Berny Düring, our Partner Technology Strategist for Business Central at Companial. With over 27 years of experience as a Microsoft Certified Trainer, he brings a wealth of expertise and knowledge to his role. Starting as a Product Manager at Navision South Africa and subsequently at Microsoft, he later established his own successful partner. Joining Companial as a franchisee in the Middle East-African market, Berny once again played a crucial role in guiding partners to grow and develop their Business Central practices through mentoring and training. He holds qualifications in Business Management, Taxation, Law, Supply Chain Management, and Computer Sciences.
- Conversational ERP: Why 2026 Is the Year We Stop Clicking and Start Talking to Our ERP - 05/02/2026
- Upgrading to a Preview Environment in Business Central 26.5 – Why You Should Care - 15/09/2025
- What’s New in Microsoft Dynamics 365 Business Central 2025 Release Wave 2 – eCommerce and Electronic Documents - 03/09/2025
Mehr über Business Central
Conversational ERP: Why 2026 Is the Year We Stop Clicking and Start Talking to Our ERP
Die Menschen haben keine Schwierigkeiten, weil ERP schwierig ist – sie haben Schwierigkeiten, weil die Benutzeroberfläche schwierig ist. Conversational ERP ...
WeiterlesenEmpowered Business Central – Release Notes Version 2.29.0.0
Entdecken Sie die Release Notes von Empowered Business Central von Companial mit neuen Funktionen, umfassenden Verbesserungen und wichtigen Updates.
WeiterlesenWAIR
WAIR strongly recommends Companial’s ISV Partnership Program to other ISVs looking to grow.
WeiterlesenUpgrading to a Preview Environment in Business Central 26.5 – Why You Should Care
Microsoft released version 26.5 of Business Central, and with it came a small but powerful change that many of us ...
WeiterlesenWhat’s New in Microsoft Dynamics 365 Business Central 2025 Release Wave 2 – eCommerce and Electronic Documents
Over the past month, Microsoft has been releasing documentation highlighting what’s new and planned for Microsoft Dynamics 365 Business Central ...
Weiterlesen