top of page

Page Scripting Part 2: Diving Deeper

You might have already read our first blog post about the Page Scripting tool in Business Central 24. Well, in this post we will dive deeper into the following features of Page Scripting:

  • How to validate field values

  • How to create conditional clauses

  • How to add a description to the recorded page script

  • How to export and use the created Page Script on a different environment


How to validate field values

Let’s start with a small page script to show how to validate field values. During this blog post we will make that script more and more complex. If you like you can do it on your tenant (maybe not in a live tenant but in a sandbox) as well.

  • Open your Buiness Central (make sure to open the sandbox).

  • Click on the settings icon at the top right of the screen. Then select the Page Scripting (preview version) option from the menu. Please note that this is only possible in BC24 environments. Also be aware that you need the proper permissions to be able to record with the page scripting feature. Read more about those permissions in our previous blog post “BC24: Page Scripting Part 1”.

  • Start the recording. In our example, we navigated to the setup page of our app Beyond Reports.

  • On this page, we first filtered the available records to get a unique single record to validate.

  • You can validate the values of fields. Right click on the field with the value you want to validate and select Page Scripting > Validate > Current Value.

Validate Field Value
Validate Field Value

Depending on the type of the field various options are avaiable. For Boolean fields only True or False values make sense. By default the tool only gives the option "is No" (= false). If you want to validate for “True”, you have to select "is No" first and then adjust the step as follows:

  • Click on the ellipsis (...) next to the validate step in your recording and select Properties.

  • A pane at the bottom of the page scripting area is displayed, allowing you to choose more options for that validate step.

  • Choose the proper operator. For Boolean values only "Equal to" or "Not equal to" make sense. You can then put the validation value in the value box below the operator.

How to create conditional clauses

Besides the many more operator options, you can also define steps to be carried out if a certain field value is given. For our example, we can define to activate a checkbox, if it is not activated.

The page script will not fail, if you rerun it.

To create a conditional clause to a page script, do the following:

  • Rightclick the field value and choose Page Scripting > Add conditional steps when > Current Value > is No (or "is Yes").

Conditional Steps
Conditional Steps
  • The view in the page scripting will be changed and you will get a dropdownmenu on that step and "(no steps)" is displayed.

  • Continue to specify what should be done by the script, if the conditon is met. In our example we activated the checkbox.   

  • When you are done, click the "End Scope" option to close the conditional steps.

  • If needed, you can also add more conditional steps in a conditional step to make the script more complex.

How to add a description to the recorded page script

You can add a description to the page script. Select Properties from the menu of the recording.

Enter the description in the description field.

This description and all steps you made will be saved in the yaml file which can be generated from the page script.

How to export and use the created Page Script on a different environment

If you want to export your script to open it in VS Code or any other program you might use, open the properties menu of the recording and choose Save recording as... and specify a storage location.

If you want to import the page script in a different environment, switch to the new environmentr and open the page scrtipitng tool of that tenant. Then, click the file icon in the main menu and select Open Recording. Navigate to the script saved on your drive and open it.

20 views0 comments

Recent Posts

See All


bottom of page