{"title":"MediaSet.Insert(Guid) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/mediaset/mediaset-insert-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/mediaset/mediaset-insert-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/mediaset/mediaset-insert-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Adds a media object that already exists in the database to a MediaSet of a record.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"MediaSet.Insert(Guid) Method","slug":"mediasetinsertguid-method","at":0,"chars":2627},{"level":2,"title":"Syntax","slug":"syntax","at":174,"chars":65},{"level":2,"title":"Parameters","slug":"parameters","at":239,"chars":619},{"level":2,"title":"Return Value","slug":"return-value","at":858,"chars":261},{"level":2,"title":"Remarks","slug":"remarks","at":1119,"chars":178},{"level":2,"title":"Example","slug":"example","at":1297,"chars":1194},{"level":2,"title":"Related information","slug":"related-information","at":2491,"chars":136}],"text":"# MediaSet.Insert(Guid) Method\n> Version: _Available or changed with runtime version 1.0._\nAdds a media object that already exists in the database to a MediaSet of a record.\n## Syntax\n```al\n[Result := ]  MediaSet.Insert(MediaId: Guid)\n```\n## Parameters\nMediaSet\nType: mediaset-data-type\nAn instance of the mediaset-data-type data type.\nMediaId\nType: ../guid/guid-data-type\nSpecifies 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.\n## Return Value\n*[Optional] Result*\nType: ../boolean/boolean-data-type\ntrue 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.\n## Remarks\nWhen media object is inserted in a MediaSet, it is assigned in index number. See Indexing of media objects in a media set<../../devenv-working-with-media-on-records>.\n## Example\nThis example uses the Insert method and mediaset-item-method 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:\n TableA and TableB already exist\n Each table has a MediaSet data type field called Images\n Each table contains the record number '1000'.\n There is at least 1 media object in the MediaSet of record 1000 in TableA.\n  ```al\n  var\n     recA: Record TableA;\n     recB: Record TableB;\n     mediasetId: GUID;\n     Text000: Label 'Media %1 was added to MediaSet %2.';\n     Text000: Label 'The media was not added to MediaSet %1.';\n  begin\n     // Retrieves the GUID of the first media object (index number 1) in the MediaSet of record 1000 in TableA\n     recA.Get('1000');\n     MediaId := recA.Images.Item(1);\n\n     // Adds media object to the MediaSet of record 1000 in TableB based on the media object GUID\n     recB.Get('1000');\n     if recB.Images.Insert(mediaId) then begin\n         recB.Modify;\n         Message(Text000, mediaId, recB.Images.MediaId);\n     end else begin\n        Message(Text001);\n     end;\n  end;\n  ```\n## Related information\nmediaset-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}