The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.

SAVEASXML Method (TestRequestPage)

Saves a report dataset and the labels on a report as two XML (.xml) files.


TestRequestPage.SAVEASXML(Filename_Labels, Filename_Dataset)  


Type: TestRequestPage

The TestRequestPage from which you want to test saving the report dataset and labels as XML files.

Type: Text

The path and file name to which the report labels are saved. The file name extension should be .xml.

Type: Text

The path and file name to which the report dataset is saved. The file name extension should be .xml.


All filters and options that have been set on the TestRequestPage are respected in the saved report.

After you run this method, you cannot continue to interact with the TestRequestPage. If you want to continue to use the TestRequestPage variable, you must run a report again.


The following example shows the code for a test method to run a report and a request page handler method to test the request page. This example requires that you create the following:

  • A test codeunit called SaveAsXML.

  • A test method in the test codeunit called TestSaveAsXML.

  • A handler method of type RequestPageHandler called ReqPageHandler. This handler method has one parameter called RequestPage of Type TestRequestPage and Subtype Customer – Top 10 List. The RequestPage parameter is specified as VAR and is passed by reference to the handler method.

    This example also requires that you create the following global variables of the SaveAsXML codeunit.

Variable name DataType
LabelsFilename Text
DatasetFilename Text
// Add the following code to the TestSaveAsXML test method.  
LabelsFilename := TEMPORARYPATH + 'MyLabels.xml';  
DatasetFilename := TEMPORARYPATH + 'MyDataset.xml';  
  ERROR('Labels file should exist!');  
IF NOT FILE.EXISTS(DatasetFilename) THEN  
  ERROR('Dataset file should exist!');  

// Add the following code to the ReqPageHandler method.  
RequestPage.Customer.SETFILTER("No.", '20000');  
RequestPage.ChartType.VALUE('Pie chart');  

See Also

TestRequestPage Data Type