# Media.HasValue() Method
> Version: _Available or changed with runtime version 1.0._
Checks whether a Media data type field in a record has been initialized with a media object and that the specified media object exists in the database.
## Syntax
```al
HasValue :=   Media.HasValue()
```
> NOTE
> This method can be invoked using property access syntax.
## Parameters
Media
Type: media-data-type
An instance of the media-data-type data type.
## Return Value
HasValue
Type: ../boolean/boolean-data-type
true if the Media data type field in a record has been initialized with a media object and the specified media object exists in the database, otherwise false.
## Example
This example uses the HasValue method to iterate over the My Items table to determine whether media objects are available on records in the table.
The example assumes that My Items table exists and contains a Media data type field that is named Image. For information about importing media, see media-importfile-method.
The code returns a message if a record does not include a media object.
```al
 var
    myItemRec: Record "My Items";
begin
    if myItemRec.FindFirst() then begin
        repeat begin
            if not myItemRec.Image.HasValue then
                Error('Item %1 does not have a valid image', myItemRec."No.");
        end until myItemRec.Next < 1;
    end;
end;
```
## Related information
media-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

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-hasvalue-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. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/media/media-hasvalue-method/
