{"title":"TestRequestPage.SaveAsXml(Text, Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/testrequestpage/testrequestpage-saveasxml-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/testrequestpage/testrequestpage-saveasxml-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/testrequestpage/testrequestpage-saveasxml-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Saves a report data set and the labels on a report as two XML (.xml) files.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"TestRequestPage.SaveAsXml(Text, Text) Method","slug":"testrequestpagesaveasxmltext-text-method","at":0,"chars":2346},{"level":2,"title":"Syntax","slug":"syntax","at":255,"chars":95},{"level":2,"title":"Parameters","slug":"parameters","at":350,"chars":331},{"level":2,"title":"Remarks","slug":"remarks","at":681,"chars":287},{"level":2,"title":"Example","slug":"example","at":968,"chars":1235},{"level":2,"title":"Related information","slug":"related-information","at":2203,"chars":143}],"text":"# TestRequestPage.SaveAsXml(Text, Text) Method\n> Version: _Available or changed with runtime version 1.0._\nSaves a report data set and the labels on a report as two XML (.xml) files.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n TestRequestPage.SaveAsXml(ParameterFileName: Text, DataSetFileName: Text)\n```\n## Parameters\nTestRequestPage\nType: testrequestpage-data-type\nAn instance of the testrequestpage-data-type data type.\nParameterFileName\nType: ../text/text-data-type\nThe path and file name to which the paramater file is saved.\nDataSetFileName\nType: ../text/text-data-type\nThe path and file name to which the data set file is saved.\n## Remarks\nAll filters and options that have been set on the TestRequestPage are respected in the saved report.\nAfter 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.\n## Example\nThe 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:\n A test codeunit called SaveAsXML.\n A test method in the test codeunit called TestSaveAsXML.\n 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.\n```al\nvar\n    LabelsFilename: Text;\n    DatasetFilename: Text;\nbegin\n    // Add the following code to the TestSaveAsXML test method.\n    LabelsFilename := TemporaryPath + 'MyLabels.xml';\n    DatasetFilename := TemporaryPath + 'MyDataset.xml';\n    Report.Run(111);\n    if not File.Exists(LabelsFilename) then\n      Error('Labels file should exist!');\n    if not File.Exists(DatasetFilename) then\n      Error('Dataset file should exist!');\n\n    // Add the following code to the ReqPageHandler method.\n    RequestPage.Customer.SetFilter(\"No.\", '20000');\n    RequestPage.ChartType.Value('Pie chart');\n    RequestPage.SaveAsXML(LabelsFilename,DatasetFilename);\nend;\n\n```\n## Related information\ntestrequestpage-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}