Store File into BLOB Field

erugalathaerugalatha Member Posts: 120
Hi,

What is the code to take file from disk (i.e. using Common Dialog Codeunit functionality) and store it in a field of Type BLOB?

Thanks for any help.

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    myBlobField.IMPORT('*.BMP',TRUE);
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • erugalathaerugalatha Member Posts: 120
    Thank you.
    Can it be files of any type? i.e. not just .BMP
  • SavatageSavatage Member Posts: 7,142
    From Help..
    Sub Type

    Use this property to provide additional information about what will be contained in this field.
    This property only applies to BLOB fields.


    Settings: The SubType settings are:
    Bitmap, Memo, User defined information User-Defined (default)

    Comments
    When you use C/AL functions IMPORT and EXPORT, the system will provide a dialog window from which the user can pick the BLOB to import or export.

    Based on your selection here, the system will show only the appropriate file types. For instance, if you select Bitmap, the system shows only files with the extension .bmp. If you select Memo, the system shows only files with the extension .txt. If you select User-Defined, the system shows all files.
  • erugalathaerugalatha Member Posts: 120
    Thank you.
  • erugalathaerugalatha Member Posts: 120
    Is it possible to get the filename and file path from the dialog box of the BLOB.IMPORT('*.*', TRUE) function?

    i.e. I want to store the filename and file path in the Filename and FilePath text fields on the record.

    It seems you have to pass in the filename to the IMPORT function but I want to use the filename and filepath that the user selects to store in other fields.

    In the help it suggests to use ImportedName := with a DataType of Filename ... as far as I can tell this DataType is not available in Navision.

    Thank you.
  • rdwyerrdwyer Member Posts: 10
    Has anyone had any luck using the BLOB SubType field? According to MS support, it doesn't serve any purpose..

    IE: if the Subtype was set to Txt, I would expect the Common Dialog to default to "Files of type" txt..
  • ara3nara3n Member Posts: 9,256
    Hello Rdwyer

    Take a look at this thread on how to select a file. You can then use this import the file into blob.


    http://www.mibuso.com/forum/viewtopic.php?t=14834&highlight=filename


    You can store the file name as string as well as file type in a separate field.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Maria-SMaria-S Member Posts: 90
    Hello,
    Has anyone had any luck using the BLOB SubType field? According to MS support, it doesn't serve any purpose..

    IE: if the Subtype was set to Txt, I would expect the Common Dialog to default to "Files of type" txt..

    For me the Memo option works fine, but User-Defined (both with and without angle braces <>) still gives *.bmp extension ](*,)
  • xdimidrolxxdimidrolx Member Posts: 6
    hi All, Is there any possibility to define the format of file stored in BLOB field (*.jpeg; *.bmp; *.tiff)?
Sign In or Register to comment.