Editar

Partilhar via


TestRequestPage.SaveAsXml(Text, Text) Method

Version: Available or changed with runtime version 1.0.

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

Note

This method is supported only in Business Central on-premises.

Syntax

 TestRequestPage.SaveAsXml(ParameterFileName: Text, DataSetFileName: Text)

Parameters

TestRequestPage
 Type: TestRequestPage
An instance of the TestRequestPage data type.

ParameterFileName
 Type: Text
The path and file name to which the paramater file is saved.

DataSetFileName
 Type: Text
The path and file name to which the data set file is saved.

Remarks

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.

Example

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.
var
    LabelsFilename: Text;
    DatasetFilename: Text;
begin
    // Add the following code to the TestSaveAsXML test method.  
    LabelsFilename := TemporaryPath + 'MyLabels.xml';  
    DatasetFilename := TemporaryPath + 'MyDataset.xml';  
    Report.Run(111);  
    if not File.Exists(LabelsFilename) then  
      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');  
    RequestPage.SaveAsXML(LabelsFilename,DatasetFilename);  
end;
  

TestRequestPage Data Type
Get Started with AL
Developing Extensions