Parsing RunRequestPage output using XML Buffer


RunRequestPage allows developers to record the request page settings of a Dynamics NAV/Business Central report without actually running the report. The output of this command is an xml string.


//XMLParameters: Text;

XmlParameters := REPORT.RUNREQUESTPAGE(50000);

What if we want to process the report in certain conditions explicitly defined by the report options? We need to be able in this case to parse the output of RunRequestPage.

Simple enough. One way is using XMLDocument LoadXml and load the string into a DotNet variable and use DotNet functions to get the value of the nodes.

If you want to avoid using DotNet you could use “XML Buffer Writer” codeunit (1235) and “XML Buffer” table (1235) in a codeunit called from an action.

XMLBuffer, XMLSpecialInterestNode : Record 1235;

XMLBufferWriter : Codeunit 1235;

First, we’re running the request page for report 50000. This will open up the request page, allowing the user to set all options/filters. Once finished click ok.

All the options/filters for the report will be recorded in the string XmlParameters.

Secondly, we load the xml string into an xml structure inside NAV, using table and codeunit 1235. This is done via function InitializeXMLBufferFromText from codeunit 1235.

We can then filter the entries and locate the option we are interested in.

In my case I had a report option “Run Later” … if this option is true I will do a different type of processing than just running the report. Think in terms of what you could do to a report beside running it: keep track of run time, email output … 


Invoking Azure Functions to replace DOT NET calls in C/AL or AL


Recently Microsoft announced that dotnet can still be used with installations on premise of Dynamics 365 Business Central.

However, if our extension is to make it in the cloud the code leveraging dot net needs to be replaced with http api calls.

In this example I will show how a legacy C/AL code using dot net can be replaced with a call to an Azure function to achieve the original goal of validating a posting code.


  • Either Table 18 was modified and additional code was added in “Post Code” Validate trigger with Regex class entities to perform validation on post codes.
  • Or, the additional validation is executed when the Post Code Validate in standard is finished and a subscriber to Post Code Validate exists in our extension and is triggered, but still contains dot net code(RegularExpressions class entitites) as we’re only dealing with on-premise (target=internal in app.json)


I want the additional validation to be executed when the standard validation is finished and the additional validation to not contain dotnet calls.


  1. In a new AL project add a new codeunit:


2. The codeunit itself contains an event subscriber to Table18.Validate.PostCode.

(Use “teventsub” snippet to get the quick scaffolding of the event subscriber)


When the subscriber is triggered we are executing an Azure Function call: azfnvalidate-us-ca-zipcode. We’re retrieving a json object whose content is : {“PCValid” : true} or {“PCValid” : false}.

3. Write the Azure Function with Visual Studio Code


  • Azure subscription
  • install C# extension
  • Azure Function Core Tools extension
  • install .net core (use npm or chocolatey)
  • Azure CLI Tools


A good guide to get you started with Azure Functions is here.

Once you have the default “Hello World” Azure Function created, replace your Run function with:


Publishing the function in Azure should generate a record in your chosen storage:AzureFninPortal


  1. Once published we can quickly spin a test for the new Azure Function in a web browser window:


2. Removing the “W” in the previous test, triggers the Azure Function to return above json.


3. Let’s test now the validation in Business Central:


Therefore, to replace a set of dotnet calls we need a worker placed somewhere else other than in AL or C/AL and a caller of that worker services placed in the extension. In my example use a codeunit (caller) in the extension range with a subscriber event defined that calls an Azure function(worker).

What other methods are you employing to achieve similar results ?

If you liked this article bookmark my blog or follow me for more stuff about NAV and Business Central.

NAV Upgrade Notes – Turning Comments into Notes using .NET


Upgrading a NAV AddOn is not solely merging code and upgrading the database through all NAV versions in between source and target. It involves analysis and prototyping of present AddOn features into features existent in the latest NAV versions. We often ask ourselves how can we replace feature X in our AddOn hosted on a NAV 2009 installation with the new feature Y in NAV 2017?

Sometimes the answer is Yes: we can merge AddOn functionality with existent features in standard. The benefit is major.

Take Comment Line table for example. Almost any AddOn has a storage place for AddOn entities to record comments or notes.

Why keep them recorded in a table in ISV’s range when we could take advantage of an existent standard table perfect for this purpose? Table Record Link was introduced in NAV 2013 and can keep track of notes and links.

The short demo below assumes the existence of:

  • a table “Generic Entity”
  • a table “Generic Entity Comment”
  • a card page “Generic Entity Card”
  • a list page “Generic Entity Comments”
  •  codeunit “Upgrade Notes 1”

To generate notes for each comment in table “Generic Entity Comment” run the codeunit 90003″Upgrade Note 1″.

The text itself resides in a Text field in “Generic Entity Comment”, but “Record Link” table has a BLOB field for recording the text. Therefore I needed to move text from “Generic Entity Comment”Comment field into a BLOB field in “Record Link”.


I wanted to use .NET here not only for exercising my rusty .NET muscles, but recording Danish characters in a BLOB proved to be a non-trivial job. So I used MemoryStream class with BinaryWriter which comes equipped with character encoding capabilities.

For a simple demo follow steps 1-4 below:


Code used is available for download here.