Modifica

File.View(Text [, Boolean]) Method

Version: Available or changed with runtime version 15.0.

Opens a file from server computer on the client computer in preview mode. The client computer is the computer that is running the browser that accesses the web client.

Note

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

Syntax

[Ok := ]  File.View(FromFile: Text [, AllowDownloadAndPrint: Boolean])

Note

This method can be invoked without specifying the data type name.

Parameters

FromFile
 Type: Text
The name of the file on the server that you want to preview on the client computer.

[Optional] AllowDownloadAndPrint
 Type: Boolean
Whether to allow the user to download or print the file from the client or not.

Return Value

[Optional] Ok
 Type: Boolean
true if the viewer was opened on the client; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

This method works only in Business Central on-premises environments. For online environments, use File.ViewFromStream.

Example

This example shows how to use the File.View method to preview a file that resides on the Business Central server on the client computer.

procedure ViewServerFileOnClient()
var
    ServerFileName: Text;
    Success: Boolean;
begin
    // Full path to a file that exists on the Business Central server computer
    ServerFileName := 'C:\Temp\Top10Customers.pdf';

    // Open the file on the client computer in preview mode,
    // allowing the user to download and print it
    Success := File.View(ServerFileName, true);

    // Handle the case where the file could not be displayed
    if not Success then
        Error('Failed to display the file.');
end;

Tip

The base application uses this method to view PDF attachments on documents like sales orders, items, and more. Learn more in the Microsoft.Foundation.Attachment reference.

File data type
Getting started with AL
Developing extensions