Illustration of a magnifying glass over a document labeled Page Script, surrounded by gear icons and the text Unlocking Hidden Features of Page Scripting.

Conducting UAT and Hidden Features of Page Scripting

8 min read

In this blog post, we’ll explore how to effectively conduct UAT in Business Central and unlock the hidden features of Page Scripting.

User Acceptance Testing is a critical step in the software development lifecycle. It involves end-users testing the software in real-world scenarios to ensure it meets their needs and expectations. The main objectives of UAT are to:

  1. Validate Business Requirements: Ensure that the software performs as expected according to the business requirements.
  2. Identify Bugs and Issues: Detect any defects that may have been missed during earlier testing phases.
  3. Ensure Usability: Verify that the software is user-friendly and intuitive.
  4. Confirm Readiness for Production: Ensure that the software is ready for deployment and use in a live environment.

Key Steps in Conducting UAT in Business Central

Define UAT Scope and Objectives

  • Identify the key functionalities and processes that need to be tested.
  • Set clear objectives for what the UAT aims to achieve.

Best tips for that:

  • Start Small and Scale Gradually (Begin with simple tests and gradually increase complexity)
  • Collaborate with End-Users (Involve end-users in the scripting process to ensure that scripts accurately reflect real-world scenarios)
  • Maintain and Update Scripts (Regularly review and update your scripts to ensure they remain relevant and effective)
  • Focus on Usability (Ensure that scripts are easy to use and understand, even for non-technical users)

Develop UAT Test Cases

  • Create detailed test cases based on user requirements and business scenarios.
  • Ensure that test cases cover all critical functionalities and edge cases.

Prepare the UAT Business Central Environment

  • Set up a testing environment that mirrors the production environment.
  • Ensure that all necessary data and configurations are in place.

Execute Test Cases

  • Involve end-users in executing the test cases.
  • Use Page Scripting to automate repetitive and complex test scenarios.

Creating simple UAT and exploring hidden features trough examples

When Business Central environment is open, you can find Page Scripting functionality in Settings:

Business Central Settings pane with the Page scripting (Preview) link highlighted

New side panel is shown:

Page Scripting side panel explaining recording, with Start new and Open buttons

By clicking “Start New”, you will automatically start recording of new UAT:

Page Scripting panel recording, showing no steps recorded yet

Let’s create simple UAT of creating Item:

Once clicked from Role Center to go to Item Page:

Business Central navigation menu with the Items list link being selected

or searched:

Tell me what you want to do search for Item, listing the Items page

Navigation to Items page will automatically be logged and displayed in Page Scripting windows so you can track steps:

Page Scripting recording panel logging the step Page Items was shown

While recording is still active you can click on Three dots on UAT line:

Step context menu offering Properties, Add Step, Delete and Make this an optional page

You will be able to Delete that line if you made an error and clicked or inputted something which you wouldn’t include in your UAT, make page optional (not applicable on this test which we are currently making, but will be explained later), and Add Step where currently there is only Wait action.

From doing some tests, I would recommend using Wait action after page opening, especially if there is on page background loading. Sometimes UAT goes too fast and next lines result and false error.

Add Step submenu with the Wait step about to be selected

After added, Wait line will appear and also Properties for it will open:

A Wait step set to 1000 milliseconds in the Page Scripting properties pane

Here you could define for how long to wait, by default its 1000ms (1 second).

Let’s move forward and create new Item:

The Items list page with the New action being clicked

Select a template for a new item dialog offering the Item and Service templates, with the recorded steps beside it

Item Card 1000 open beside the Page Scripting panel listing every recorded step so far

Item No. is populated and if you would like to validate it, correct step would be to input Description, it will trigger validation of No. and you can afterwards validate Item No.

For input of Description you can simply type the value:

The Item card Item section with Test Item typed into the Description field

And once you validate it by leaving that field new line in Page Scripting will be created:

The recorded step Input Test Item into Description, highlighted in the script

If you need random Description you can use here PowerFX procedure RandBetween(start,end).

So opening properties of this line:

Properties pane showing the step value as the PowerFX string Test Item

And replacing it by procedure RandBetween:

PowerFX IntelliSense in the value box suggesting Rand, RandBetween and Radians

By Crtl+Space there IntelliSense will appear also, if you open parenthesis it will also show you parameters of method:

The RandBetween signature tooltip describing its bottom and top parameters

Now step is edited:

The step rewritten to Input RandBetween(100000,99999999) into Description

If we run this step only:

The Item card Description filled with the random number the RandBetween step produced

Description gets new numeric random value, let’s make it even more complex:

Description reading Test Item 37306708, built by concatenating Test Item with Text(RandBetween(...))

In order to add prefix in front of random number you would need to use Concatenate method. Now we get what it seems to be realistic Item Description.

You can find more PowerFX methods on: Formula reference – Power Apps – Power Platform | Microsoft Learn


Let’s move back to validation of Item No., if you would like to validate the content you would need to right click on the field and then select Validate > Current value > is xxx.

Right-click menu on the No. field: Page Scripting, Validate, Current value, is 1000

Here down-side is that you need to select “is XXX” in order to add line in Page Scripting and than you can edit it further with more options:

A Validate No. is 1000 step with the Operator list open on Equal to, Not equal to and the rest

What I would validate here is that No. Series worked fine, and that No. was automatically pre-filled:

The step changed to Validate No. is not empty, using the Not equal to operator

Value Storage

One important method from PowerFX was missing and that is Set or SaveData, with it you would be able to set value of global variable, which temporarily holds a piece of information, such as the number of times the user has selected a button or the result of a data operation.

What to use instead?

Clipboard

As you may have noticed, there is Copy/Page PowerFX action which are supported:

Right-click menu on the No. field with the Page Scripting Copy action highlighted

By copying it will be available during UAT, even on different pages and with multiple values copied. Let’s copy multiple fields:

A Copy value from Description step added below Copy value from No.

Trying to Paste:

The Paste submenu listing both stored clipboard values, Item Card Description and Item Card No.

Showing the use cases now in next points.

Editing value in field

We have Description with trailing white space:

The Item card Description value selected, showing the trailing white space it carries

First, save it on Clipboard storage:

Right-click Copy on the Description field, saving its value to clipboard storage

Then do Paste to same field and open properties:

Paste submenu offering the stored Item Card Description value and Session Info

Shows like this:

The recorded step Input Clipboard.'Item Card - Description' with its value in Properties

Here you can also play around and pull from storage by accessing Clipboard, it’s in format Page Name + Field Name:

PowerFX IntelliSense listing the two clipboard entries, Item Card Description and Item Card No.

But we want to remove white space from Description:

The step wrapped in Trim(Clipboard.'Item Card - Description'), removing the trailing space

There are lots of PowerFX methos which can be used, this is just example to show how to modify existing value.

Cross-Page Value

Let’s take Item which we created earlier and copy Item No. from the page:

Right-click Copy on the Item card No. field, storing 1000 for use on another page

Go to Sales Order Page and add Sales Order Line by type of Item, try to Paste:

A sales order line where Paste offers the Item Card No. value copied on the item card

You will see value from Item Card, field No. that can be Pasted to Sales Order Line – Item No. field.

The recorded script showing the copy on the item card and the paste into the sales order line

Here you can see cross-page transfer by Clipboard.

On same way you can do Copy and by Pasting editing the value without editing reference from which we copied from.

Custom Validation Hack

You are very limited when we speak about validations and checks, but there are currently workarounds.

If we validate Sales Order Item No. to it’s value:

Validate submenu on a sales order line offering is 1000 and is equal to clipboard entry

Go to properties:

A Validate No. is 1000 step with its Equal to operator and quoted value in Properties

Here we could use IfError to do validations:

The IfError signature tooltip describing its value and fallback arguments

Again, most common would be to store to storage of Clipboard than to do validations here, since Clipboard is Text always, you will need to do conversion with Value method:

A failing validation step reporting it was expecting true but got 1000

Still, we get and error since IfError returns check result, we need to add additional If here:

The step wrapped in If, still failing with expecting 1000 but got 1000 - a formatting mismatch

Now we gets the value 1000 but it doesn’t match?!?!

Even though all is displayed same, problem is with formatting, as said before most of the things are working from Text and you would need methods to do the conversions:

The expression rewritten with Text(1000) so the comparison returns matching types

We can simply add Text method and 1000 as parameter to match if success.

The validation step passing, with the finished IfError, If and Text expression in Properties

Now all is good!

You could do same with Add conditional steps when :

Add conditional steps when submenu offering is 1000 and is equal to clipboard entry

Here you would be able to do custom validations on same principle and extend possibility of conditional steps.


Saving Page Scripts

Each of scripts which you created can be saved and makes sense to do. Since you will be spending some time creating good scripts. And in order for you to use it later multiple times or share it, you will need to save it:

The Save recording button in the Page Scripting toolbar

By pressing Save Recording:

Warning that the saved file might contain sensitive data, asking whether to continue

It will first ask you to confirm save, since it could contain sensitive information if you have not used demo data, but instead, used client’s production data.

Upon confirmation:

Save dialog with the file name Recording.yml and the yml and yaml file types

You would just need to name it and save it!

Later on when you want to use it you would just use Open recording... button:

The Page Scripting file menu offering New recording and Open recording

And it will load up saved version.

Saved version in Yaml is pretty readable:

The saved Recording.yml open in an editor, listing navigate, page-shown, wait and invoke steps

Here you can also edit the script without Business Central, it’s not that hard as it seems to be.

Additionally, you can share in same environment link of the script:

The share menu offering Copy link, for handing the script to someone by URL

You can share it with your colleagues, and they would be able to reproduce quickly some error, create an example multiple times without you being assisting them and many more use cases.

URL Share to Cross-Environment or Company

Link is base64 encoded, containing Page Scripting steps, zipped and encoded:

Text
https://businesscentral.dynamics.com/Production/do?dc=0&company=Testing#open-replaylog=H4sIAAAAAAAAA7VVUW-bMBB-z6848ZRICSF76FREI7VdNUXq2JSk6-PkwSWzYmxkm2T797MNBDKykkwaEhI-33333Xdnw0mGISwxETKlfDtQmkgdDgByKTaUmb2Hl9Uiflqt4NN9fP_xaWlcMFfWZQL6V248ONnTLdFoTAAmfosOwT4TyMnWuCw0ZvBMlXb2FFUiaa6p4CHEVTRo4dxUC9kGT9QPceAuTolCJlhjn0POREpYCBvCVElHFlzTDBdpCN_1u272LwYEooS45dzlj6b1Eg5EgUvvt0gdCC2TWeAQZkEQdHFfjRNshIRoT1iBc-sVTctvyChjVBnNedqulvK92F2uYqu8JW6a-qw_SUoaj4JrKdi3GA9ur0yxdulq2wnvhXOweyB4I4xZN7Jc16AVMkx0yX2NWc78Tru0LLrdmt3c9rWrgiagLa6dIas4AW7YU2Pr62Sv4G9x78hfE25r_CzErsg_7_4qdO1wovbldf3ZioQJhek_9eL_al8S868bHcfzkci0_2zP3t_0MbYzPWkw-4cjL3TfYTyS605DRcgGbCgyQ_JDw81tudsghDtzSBMjIDfv0FujKhvkjT3wxqZNP_VwSXj6gPqAyIf2JgmC8W31jEajc8NluNdXz1vwFcULkhwvL8q1qMKO0rYqOzubJpSmF_whrpIzFv6JjJ7nliJHSUoZonlXmq8VldZcCL81C9Exfk4VcKGjaWOp6y6l8LxalMFJCqexPP5SfwPMph5FYwcAAA&zip=1&base64=1

The shared script replayed in the TEST environment, with its steps listed

Then I will change Environment and Company and copy only this part:

Text
/do?dc=0&company=Testing#open-replaylog=H4sIAAAAAAAAA7VVUW-bMBB-z6848ZRICSF76FREI7VdNUXq2JSk6-PkwSWzYmxkm2T797MNBDKykkwaEhI-33333Xdnw0mGISwxETKlfDtQmkgdDgByKTaUmb2Hl9Uiflqt4NN9fP_xaWlcMFfWZQL6V248ONnTLdFoTAAmfosOwT4TyMnWuCw0ZvBMlXb2FFUiaa6p4CHEVTRo4dxUC9kGT9QPceAuTolCJlhjn0POREpYCBvCVElHFlzTDBdpCN_1u272LwYEooS45dzlj6b1Eg5EgUvvt0gdCC2TWeAQZkEQdHFfjRNshIRoT1iBc-sVTctvyChjVBnNedqulvK92F2uYqu8JW6a-qw_SUoaj4JrKdi3GA9ur0yxdulq2wnvhXOweyB4I4xZN7Jc16AVMkx0yX2NWc78Tru0LLrdmt3c9rWrgiagLa6dIas4AW7YU2Pr62Sv4G9x78hfE25r_CzErsg_7_4qdO1wovbldf3ZioQJhek_9eL_al8S868bHcfzkci0_2zP3t_0MbYzPWkw-4cjL3TfYTyS605DRcgGbCgyQ_JDw81tudsghDtzSBMjIDfv0FujKhvkjT3wxqZNP_VwSXj6gPqAyIf2JgmC8W31jEajc8NluNdXz1vwFcULkhwvL8q1qMKO0rYqOzubJpSmF_whrpIzFv6JjJ7nliJHSUoZonlXmq8VldZcCL81C9Exfk4VcKGjaWOp6y6l8LxalMFJCqexPP5SfwPMph5FYwcAAA&zip=1&base64=1

The same shared script opened against the LIVE environment

So, same script opens up in different environment and different company. Meaning, that you could have just URL collection in some document to share and not each of the Yaml files. I thought about limitations and did tests, so far created some big Page Scripts and wasn’t able to break it, which is a good thing!

Generally, you would be able to do same; by copying second part of the link to your environment you will get same script on your side. Script was just recoding of first example with Concatenate method.


What’s missing in Page Scripting?

Currently I think this is just beginning as it also says that it is Preview feature. Lot of features in my opinion which should exist are currently not available but doesn’t mean they won’t be coming.

Missing features:

  • Creating suite from multiple recorded Yaml files/ UAT Tests from UI
  • Extending number of supported Power FX functions (even though it says it supports Power FX and there is link to formula reference page in Docs, not all are supported
  • There should be execution duration of UAT tests
  • Error validations (currently when error happen during validation, you are not able to validate it and UAT step also returns success, even though there is an error notification on screen, only if there is an Error message strictly, than it shows up in Page Scripting as Page Error)
  • F5 (Refresh page) missing, especially when error happens after validation, in order to continue you would refresh current page

One good picture about Microsoft being aware of some of the things:

A Microsoft session slide, Good to know, listing Page Scripting shortcomings and known issues

URL to video: In preview: User acceptance testing with the Page Scripting tool (youtube.com)

Until these features are added we could still use this tool for reproducing issues, creating learn scenarios, and creating basic UAT’s.


What’s next?

In next blog post about Page Scripting we be covering designing different types of Page Scrips, and some more “hacks” will be included.

We will be using all the knowledge what we covered in:

Prerequisite for Business Central Page Scripting – Stefan’s BC Blog (ssosic.com)

And current blog post, to create UAT’s, create error reproducing scripts, demo data creation and demo process capturing for learning business processes.

Stay tuned!

Related posts

Comments

    Leave a comment

    Reviewed before it appears.