“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.
NAV C/AL Code
RecordLink.RESET;
RecordLink.SETCURRENTKEY(Company,”Refer to”);
RecordLink.SETRANGE(Company,COMPANYNAME);
RecordLink.SETRANGE(“Refer to”,”No.”);
IF NOT RecordLink.FINDSET THEN EXIT;
IF FileToUpload = ” THEN EXIT;
FileManagement.BLOBImportFromServerFile(recTempBlob,FileManagement.UploadFileSilent(FileToUpload));
ItemPicture.SETRANGE(“No.”,”No.”);
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;
Page 346 Item Picture
OnClosePage()
itemPicture.RESET;
itemPicture.SETRANGE(“No.”,”No.”);
IF itemPicture.Picture.HASVALUE THEN BEGIN
itemPicture.CALCFIELDS(Picture);
CLEAR(itemPicture.Picture);
itemPicture.MODIFY;
END;
END;