RecordRef.AddLink(Text [, Text]) Method

Version: Available or changed with runtime version 1.0.

Adds a link to a record in a table.

Syntax

[ID := ]  RecordRef.AddLink(URL: Text [, Description: Text])

Parameters

RecordRef
 Type: RecordRef
An instance of the RecordRef data type.

URL
 Type: Text
The link that you want to add to the record.

[Optional] Description
 Type: Text
Optional description of the link.

Return Value

[Optional] ID
 Type: Integer
The ID of the URL that you want to add to the record. Every time that you add a link to a page or a table, an entry is created in the Record Link system table. Each entry is given an ID.

Remarks

The URL can be a link to a Web site, a file stored on the local or on a remote computer, or a link to a Dynamics 365 page. You can then view the link in the Links FactBox on pages that display the record.

Example

The following example adds a link to a record in the Customer table. The code starts by opening table 18 (Customer) as a RecordRef variable that is named CustomerRecref. The Field Method (RecordRef) creates a FieldRef variable that is named MyFieldRef for the first field (No.). Next, MyFieldRef.Value is set to record 01121212. The Find Method (RecordRef) method searches the records for record no. 01121212. If the record is found, then the AddLink method adds a link to the record. The link is assigned a link ID, which is stored in the LinkID variable. The link ID is displayed in a message box. You can view the link you added in the Links FactBox on the Customer List or Customer Card pages.

var
    CustomerNum: Code;
    varLink: Text;
    CustomerRecref: RecordRef;
    MyFieldRef: FieldRef;
    LinkID: Integer;
    Text000: Label 'The link with ID %1 has been added.';
    Text001: Label 'The customer cannot be found.';
begin  
    CustomerNum := '01121212';  
    CustomerRecref.Open(18);  
    MyFieldRef := CustomerRecref.Field(1);  
    MyFieldRef.Value := CustomerNum;  
    if CustomerRecref.Find('=') then begin  
      LinkID := CustomerRecref.AddLink(varLink);  
      Message(Text000, LinkID);  
    end else
      Message(Text001);  
end;

RecordRef Data Type
Get Started with AL
Developing Extensions