Query.SaveAsXml(Integer, Text) Method
Version: Available or changed with runtime version 1.0.
Saves the resulting data set of a query as an .xml file.
Note
This method is supported only in Business Central on-premises.
Syntax
[Ok := ] Query.SaveAsXml(Number: Integer, FileName: Text)
Parameters
Number
Type: Integer
The ID of the query object that you want to save as an .xml file. If the query that you specify does not exist, then a run-time error occurs.
FileName
Type: Text
The path and name of the file that you want to save the query to.
Return Value
[Optional] Ok
Type: Boolean
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
Remarks
When the SaveAsXML method is called, the dataset is generated and then saved in XML format in the file and location that is designated by the FileName parameter.
The SaveAsXML method can be called at any place in the code and does not require that the Close, Open, or Read methods are called before it. When the SaveAsXML method is called, a new instance of the query is created. The query is implicitly opened, read, and closed. If there is currently a dataset in the opened state when the SaveAsXML method is called, then that instance is closed. This means that the following code is unauthorized because the query is not open on the second Read call.
Query.Open;
Query.Read;
Query.SaveAsXML('c:\test.xml');
Query.Read;
The correct code for this example is as follows.
Query.Open;
Query.Read;
Query.SaveAsXML('c:\test.xml');
Query.Open;
Query.Read;
Example
The following example shows how to save a query with the name My Customer Query as an .xml file. The file is given the name myquery.xml and is saved on the c: drive of the computer running Dynamics 365 Business Central service.
var
MyCustomerQuery: Query "My Customer Query";
OK: Boolean;
Text000: Label 'Query was not saved.';
begin
OK := MyCustomerQuery.SaveAsXML('c:\myquery.xml');
if not OK then
Error(Text000);
end;
If the file cannot be saved, then the follow message appears:
Query not saved.
See Also
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示