“How to” display picture from file in Item Picture Page


Below a short procedure to visualize a linked picture from a picture file (example file with “.GIF” extension) into the “Item Picture Page”.

The System load the image file in a BLOB field and after displays it on the picture page; at the close of the page the image is deleted from the item table in order to lighten the System; same procedure can be used in reports and can also be used in old versions of NAV… in this case NAV 2013.

imag1imgage2

image3.png

NAV C/AL Code

On Image Button of Item Card
// CHECK DATA IN RECORDLINK TABLE
RecordLink.RESET;
RecordLink.SETCURRENTKEY(Company,”Refer to”);
RecordLink.SETRANGE(Company,COMPANYNAME);
RecordLink.SETRANGE(“Refer to”,”No.”);
IF NOT RecordLink.FINDSET THEN EXIT;
FileToUpload := RecordLink.URL4;   //Custom field with link for image
IF FileToUpload = ” THEN EXIT;
//IMPORT IMAGE FROM FILE USING FILE MANAGEMENT
FileManagement.BLOBImportFromServerFile(recTempBlob,FileManagement.UploadFileSilent(FileToUpload));
ItemPicture.RESET;
ItemPicture.SETRANGE(“No.”,”No.”);
IF ItemPicture.FINDSET THEN BEGIN
ItemPicture.Picture := recTempBlob.Blob;
ItemPicture.MODIFY;
ItemPicture.RESET;
ItemPicture.SETRANGE(“No.”,”No.”);

// OPEN PAGE 346 Item Picture > Visualize Item Image
PagePicture.SETTABLEVIEW(ItemPicture);
PagePicture.RUN;
END;

//Image Cleaning
Page 346 Item Picture
OnClosePage()
itemPicture.RESET;
itemPicture.SETRANGE(“No.”,”No.”);
IF itemPicture.FINDSET THEN BEGIN
IF itemPicture.Picture.HASVALUE THEN BEGIN
itemPicture.CALCFIELDS(Picture);
CLEAR(itemPicture.Picture);
itemPicture.MODIFY;
END;
END;
Annunci