Business Central Musings

For the things we have to learn before we can do them, we learn by doing them

Parsing RunRequestPage output using XML Buffer

Share This Post

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 … 


Share This Post

Related Articles

2 Responses

  1. Hi, nice to meet you.
    Thank you for sharing this article.
    Can you help me?
    I have parsed the output of RunRequestPage using an XML Buffer, and then I added Elements and Attributes to filter a DataItem. 
    My question is how to convert the XML Buffer to Text so I can use it as XMLParameters to run Report.SaveAs?
    Thank you in advance.

    1. See if you can find any useful functions in XMLBuffer, XMLSpecialInterestNode : Record 1235; XMLBufferWriter : Codeunit 1235;
      If not ,you might have to do something like concatenating the xml buffer records to get back to xmlparameters.

Leave a Reply

Recent Posts

Get Notified About New Posts

Verified by MonsterInsights