{"title":"Media.MediaId() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/media/media-mediaid-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/media/media-mediaid-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/media/media-mediaid-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":"Gets the unique identifier of a media object on a record.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":118,"chars":115},{"level":2,"title":"Parameters","slug":"parameters","at":233,"chars":88},{"level":2,"title":"Return Value","slug":"return-value","at":321,"chars":99},{"level":2,"title":"Remarks","slug":"remarks","at":420,"chars":292},{"level":2,"title":"Example","slug":"example","at":712,"chars":521},{"level":2,"title":"Related information","slug":"related-information","at":1233,"chars":133}],"text":"> Version: _Available or changed with runtime version 1.0._\nGets the unique identifier of a media object on a record.\n## Syntax\n```al\nMediaId :=   Media.MediaId()\n```\n> NOTE\n> This method can be invoked using property access syntax.\n## Parameters\nMedia\nType: media-data-type\nAn instance of the media-data-type data type.\n## Return Value\nMediaId\nType: ../guid/guid-data-type\nThe GUID of the Media object in the database.\n## Remarks\nWhen a media is imported on the Media data type field of table record, the media is given a GUID and stored in the system table 2000000184 Tenant Media of the application database. The GUID is then included in the Media data type field as a reference to the media in the database.\n## Example\nThis example uses the MediaId method to get the GUID of the media object that is used on item number 1 in the a the table named My Items.\nThe example assumes that the My Items table already exists and has a Media data type field named Image.\n```al\n var\n    myItemRec: Record \"My Items\";\n    imageID: GUID;\n    Text000: Label 'Item %1 has a media object with the following ID: %2';\nbegin\n    myItemRec.Get('1');\n    mediaGuid := myItemRec.Image.MediaId;\n    Message(Text000, myItemRec.\"No.\", imageID);\nend;\n```\n## Related information\nmedia-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}