Open File from BLOB data

Jatin_PatelJatin_Patel Member Posts: 200
Hello,

I have one table like this:
Name Datatype Size
No. code 20
name text 250
Filelocation text 250
attachment blob

i want to copy all file stored in this table at any temporary location in folder.
and also want be opened all files in appropriate application like (txt in notepad,doc in word etc.)
when i close all temporary file i wanted to be deleted all file from temporary location but remain in table.
how can i do this?
Please tell me some code or Suggestion...

Thanks....
Jatin Patel
Microsoft Dynamics NAV Consultant
Jatin's Blog

Answers

  • geronimogeronimo Member Posts: 90
    as far as i know you can stream the files to a temporary location and then open them by using the hyperlink function.

    however it depends on your client version if this function can be used or not.
  • vaprogvaprog Member Posts: 1,139
    I suggest you have a look at the table 5062 Attachment.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I guess it's your lucky day:
    IF recMyTable.FINDSET THEN
      REPEAT
        recMyTable.CALCFIELDS(attachment);
        IF recMyTable.attachment.HASVALUE THEN BEGIN
          recMyTable.attachment.EXPORT('c:\Temp\' + recMyTable.name,FALSE);
          HYPERLINK('c:\Temp\' + recMyTable.name);
        END;
      UNTIL recMyTable.NEXT = 0;
    
    WHILE intWait < 10 DO BEGIN
      SLEEP(1000);
      intWait := intWait + 1;
    END;
    
    IF recMyTable.FINDSET THEN
      REPEAT
        recMyTable.CALCFIELDS(attachment);
        IF recMyTable.attachment.HASVALUE THEN
          FILE.ERASE('c:\Temp\' + recMyTable.name);
      UNTIL recMyTable.NEXT = 0;
    

    You won't be able to detect when the application is closed, as HYPERLINK runs the application without feedback to NAV. That's why I used a loop to pause NAV execution, before removing the files. If the files are removed before the applications are able to load the files, you will have to increase this pause loop.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.