The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
Returns the report data structure as structured XML that is compatible with Microsoft Word custom XML parts.
The method has an instance call and a static call. The following code shows the syntax of the WORDXMLPART method. The first line of code is the syntax for an instance method call. The second line of code is the syntax for a static method call.
String := ReportVariable.WORDXMLPART([ExtendedFormat])
String := REPORT.WORDXMLPART(Number[, ExtendedFormat])
If you set this variable to true, then XML elements will include the following attributes attributes:
Specifies the element type as defined for the report in Report Designer.
Parameteris typically used for elements, such as captions.
Specifies the ID that is assigned to the element by its ID Property.
Specifies the Dynamics 365 data type of the element.
If you omit this parameter or set it to false, then the element attributes are not included in the XML. This is the recommended setting when you will use the Word XML part in Word for modifying the report layout because the XML is simpler.
The following example illustrates an XML element that has the ExtendedFormat set to false:
<CompanyName ElementType="Column" ElementId="3" DataType="OemText">
The following example illustrates the same XML with the ExtendedFormat set to true:
The ID of the report that you want to run.
If the report you specify does not exist, then a run-time error occurs.
You must use the return value; otherwise you cannot compile the object.
This method returns the data structure of the report as structured XML that complies with custom XML parts in Microsoft Word 2013. The following table provides a simplified overview of the XML that is returned by the method.
||XML namespace specification.
||Contains all the labels for the report. Labels are listed in alphabetical. The element includes labels that are related to columns that have the IncludeCaption Property set to Yes and labels that are defined in Report Label Designer.
- Label elements that are related to columns have the format
- Label elements from Report Label Designer have the format
||Top-level data item and columns. Columns are listed in alphabetical order.
The element names and values are determined by the Name property of the data item or column.
||Data items and columns that are nested in the top-level data item. Columns are listed in alphabetical order under the respective data item.|
Word custom XML parts enable you to integrate business data into Word documents. For example, the WORDXMLPART method is used internally by Dynamics 365 when you are creating report layouts in Word. You can use this method to create a custom XML part, and then, together with the SAVEASXML Method (Reports) method and additional data merging tools, you can implement your own functionality for mapping and laying out report data in Word documents. To create a custom XML part, you can save the return value to an .xml file that is encoded in UTF-16 (16-bit Unicode Transformation Format). The resultant file can be added to Word documents as a custom XML part to map the report data set as XML data.
The following example uses the WORDXMLPART method to save the data structure of Report 112 Sales Statistics in an XML file in a predefined folder C:\Report Documents. The resultant file can be used in Word as a custom XML part. To complete the example, you must also create the following global variables.
ReportAsString := REPORT.WORDXMLPART(112); SalesStatsReport.TEXTMODE(TRUE); SalesStatsReport.WRITEMODE(TRUE); SalesStatsReport.CREATE('C:\Report Documents\SalesStatsReport.xml', TextEncoding::UTF16); SalesStatsReport.WRITE(ReportAsString); SalesStatsReport.CLOSE;
The code generates the report structure as XML, and then writes the XML to the file C:\Report Documents\SalesStatsReport.xml.