Επεξεργασία

Κοινή χρήση μέσω


MediaSet.Insert(Guid) Method

Version: Available or changed with runtime version 1.0.

Adds a media object that already exists in the database to a MediaSet of a record.

Syntax

[Result := ]  MediaSet.Insert(MediaId: Guid)

Parameters

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

MediaId
 Type: Guid
Specifies the unique ID that is assigned to the media object that you want to insert. Existing media objects are stored in the system table 2000000184 Tenant Media of the application database. There are different ways of obtaining the GUID of a media object. You could identify the media object ID by looking in the table. Or programmatically, you can use either the Item function on a MediaSet data type field of a record or the MEDIAID function on Media data type field of a record.

Return Value

[Optional] Result
 Type: Boolean
true if the media is successfully added to the MediaSet, otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

When media object is inserted in a MediaSet, it is assigned in index number. For more information, see Indexing of media objects in a media set.

Example

This example uses the Insert method and Item Method (MediaSet) to take a media object that is already in the database and assigned to a record in a table (TableA), and add it to the MediaSet of a record in another table (TableB). This example assumes the following:

  • TableA and TableB already exist
  • Each table has a MediaSet data type field called Images
  • Each table contains the record number '1000'.
  • There is at least 1 media object in the MediaSet of record 1000 in TableA.
 var
    recA: Record TableA;
    recB: Record TableB;
    mediasetId: GUID;
    Text000: Label 'Media %1 was added to MediaSet %2.';
    Text000: Label 'The media was not added to MediaSet %1.';
begin
    // Retrieves the GUID of the first media object (index number 1) in the MediaSet of record 1000 in TableA
    recA.Get('1000');  
    MediaId := recA.Images.Item(1);
    
    // Adds media object to the MediaSet of record 1000 in TableB based on the media object GUID
    recB.Get('1000');
    if recB.Images.Insert(mediaId) then begin
        recB.Modify;    
        Message(Text000, mediaId, recB.Images.MediaId);
    end else begin
       Message(Text001);
    end;
end;

MediaSet Data Type
Get Started with AL
Developing Extensions