Report.WordLayout(Integer, InStream) Method

Version: Available or changed with runtime version 1.0.

Gets the Word report layout that is used on a report and returns it as a data stream.

Syntax

[Ok := ]  Report.WordLayout(Number: Integer, InStream: InStream)

Parameters

Number
 Type: Integer
The ID of the report object for which you want to get the Word report layout.

InStream
 Type: InStream
The variable in which to return the Word report layout.

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

Using the return value is optional. When you use the return value, if the Word report layout can't be retrieved at runtime, then the system returns false and no error is recorded. When you omit the return value, if the Word report layout can't be retrieved at runtime, then an error occurs, which states that the Word report couldn't be retrieved.

Example

The Report.WordLayout method will throw a runtime error if the operation fails, either if no object exists with that object ID or if no Word layout exists for that report. This code example shows how to write robust AL code to handle possible failures.

var
    layoutAsStream: InStream;
    result: Boolean;
begin
    result := Report.WordLayout(ObjectId, layoutAsStream);
    if result then
        // use the layout that now is available in the stream
    else
        // handle that no object exists with that id or that no Excel layout exists for that report
    ;
end;

If the report is known when you write the code, the safest way to avoid runtime errors is to use the scope (::) operator to reference the report object. This way you'll get a compile time error if the report doesn't exist. The example illustrates how to call WordLayout on the report MyReport using this technique:

var
    layoutAsStream: InStream;
    result: Boolean;
begin
    // if MyReport does not exist, then Report::MyReport will fail at compile time
    result := Report.WordLayout(Report::MyReport, layoutAsStream);

    if result then
        // use the layout that now is available in the stream
    else
        // handle that no Excel layout exists for that report
    ;
end;

See Also

Report Data Type
Get Started with AL
Developing Extensions