If you are going to create a processing report - it will behooooove you to make it flexible.
Just because you want to import today - doesn't mean you will not need the ability to Export or Delete these images also.
You can beef up the report to include all 3 options.
Something like this:
Variables for Request Form
ImportItem = boolean
ExportItem = boolean
DeleteItem = boolean
OnAfterGetRecord()
InvtSetup.GET;
Item.CALCFIELDS(Picture);
IF ImportItem THEN ImportItemPicture;
IF ExportItem THEN ExportItemPicture;
IF DeleteItem THEN DeleteItemPicture;
ExportItemPicture()
IF Item.Picture.HASVALUE
THEN Item.Picture.EXPORT('c:\temp\'+Item."No."+'.BMP',FALSE);
DeleteItemPicture()
IF Item.Picture.HASVALUE THEN BEGIN
CLEAR(Item.Picture);
Item.MODIFY;
END;
ImportItemPicture()
CLEAR(Item.Picture);
IF EXISTS (InvtSetup."Item BMP Path"+Item."No."+'.BMP') THEN BEGIN
Item.Picture.IMPORT(InvtSetup."Item BMP Path"+Item."No."+'.BMP',FALSE);
Item.MODIFY;
END;
//InvtSetup."Item BMP Path" : I have create a default path for my pictures & saved it in a setup table.
I am trying this through CreateOutStream function ,but still the images are not uploaded into the item table.
Please provide me a detail solution regarding this.
I would like some help in getting this to work as I have a large number of images to upload. I have created the report as listed and it compiled fine.
Should this be a process only report? Can the format of picfilename be an excel file with three columns - name of image, path to image, item no. or does it need to be .csv or .txt? Where does the picfilename get entered - in the predata section of the report code? Would it be possible to set up a request page where I could enter the picfilename rather than set it in code so I run this report in smaller batches.
1.It is a process only report.
2.You can create a table(Item Image) in require database with 3 columns Name of Image,Path,Item No.
3.Create the same report with Item Image Table as DataItem.
In request page you can add Item No.
Variable Type
F1 File
MemStream InStream
OStream OutStream
PicFileName Text
FilePath Text
RecItem Record Item
Item Image - OnAfterGetRecord()
PicFileName := STRSUBSTNO('%1%2.png',Path,Image Name);
IF FILE.EXISTS(PicFileName) THEN BEGIN
F1.OPEN(PicFileName);
F1.CREATEINSTREAM(MemStream);
RecItem.reset;
RecItem.Setrange("No.","Item No.");
if RecItem.FindFirst then
begin
RecItem.CALCFIELDS(Picture);
RecItem.Picture.CREATEOUTSTREAM(OStream);
COPYSTREAM(OStream,MemStream);
RecItem.MODIFY;
End
F1.CLOSE;
END;
Please check and modify the code as per your requirement.
Set up the table and modified the report, code is as follows...no errors on compile
there is one line in the image table...
Image Name: BF2T Y
Path: c:\user\Pictures\
Item No: BF2T Y
the image is a small .jpg file
PicFileName:= STRSUBSTNO('%1%2.jpg', Path,"Image Name");
IF FILE.EXISTS(PicFileName) THEN BEGIN
F1.OPEN(PicFileName);
F1.CREATEINSTREAM(MemStream);
RecItem.RESET;
RecItem.SETRANGE("No.","Item No");
IF RecItem.FINDFIRST THEN BEGIN
RecItem.CALCFIELDS(Picture);
RecItem.Picture.CREATEOUTSTREAM(OStream);
COPYSTREAM(OStream,MemStream);
RecItem.MODIFY;
END;
F1.CLOSE;
END;
When I run the report I get an error:
"Filter could not be applied. Could not apply filter "B1 G" to column no. "1" because the field is missing or unavailable."
Could this be a permission issue, that it is unable to access the path on my pc (Win10Pro)? I'll play with it tomorrow night.
Comments
You can try these suggestions
http://www.mibuso.com/forum/viewtopic.php?f=23&t=15070
http://dynamicsuser.net/forums/p/32976/173139.aspx
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Just because you want to import today - doesn't mean you will not need the ability to Export or Delete these images also.
You can beef up the report to include all 3 options.
Something like this:
Variables for Request Form
ImportItem = boolean
ExportItem = boolean
DeleteItem = boolean
OnAfterGetRecord()
InvtSetup.GET;
Item.CALCFIELDS(Picture);
IF ImportItem THEN ImportItemPicture;
IF ExportItem THEN ExportItemPicture;
IF DeleteItem THEN DeleteItemPicture;
ExportItemPicture()
IF Item.Picture.HASVALUE
THEN Item.Picture.EXPORT('c:\temp\'+Item."No."+'.BMP',FALSE);
DeleteItemPicture()
IF Item.Picture.HASVALUE THEN BEGIN
CLEAR(Item.Picture);
Item.MODIFY;
END;
ImportItemPicture()
CLEAR(Item.Picture);
IF EXISTS (InvtSetup."Item BMP Path"+Item."No."+'.BMP') THEN BEGIN
Item.Picture.IMPORT(InvtSetup."Item BMP Path"+Item."No."+'.BMP',FALSE);
Item.MODIFY;
END;
//InvtSetup."Item BMP Path" : I have create a default path for my pictures & saved it in a setup table.
http://www.BiloBeauty.com
http://www.autismspeaks.org
I had already tried this,but IMPORT function is not working in NAV 2013.I want to do this process in NAV 2013.
http://www.BiloBeauty.com
http://www.autismspeaks.org
Please provide me a detail solution regarding this.
Variable Type
F1 File
MemStream InStream
OStream OutStream
PicFileName Text
FilePath Text
Item - OnAfterGetRecord()
PicFileName := STRSUBSTNO('%1%2.png',FilePath,"No.");
IF FILE.EXISTS(PicFileName) THEN BEGIN
F1.OPEN(PicFileName);
F1.CREATEINSTREAM(MemStream);
Item.CALCFIELDS(Picture);
Item.Picture.CREATEOUTSTREAM(OStream);
COPYSTREAM(OStream,MemStream);
Item.MODIFY;
F1.CLOSE;
END;
Should this be a process only report? Can the format of picfilename be an excel file with three columns - name of image, path to image, item no. or does it need to be .csv or .txt? Where does the picfilename get entered - in the predata section of the report code? Would it be possible to set up a request page where I could enter the picfilename rather than set it in code so I run this report in smaller batches.
Thank you
1.It is a process only report.
2.You can create a table(Item Image) in require database with 3 columns Name of Image,Path,Item No.
3.Create the same report with Item Image Table as DataItem.
In request page you can add Item No.
Variable Type
F1 File
MemStream InStream
OStream OutStream
PicFileName Text
FilePath Text
RecItem Record Item
Item Image - OnAfterGetRecord()
PicFileName := STRSUBSTNO('%1%2.png',Path,Image Name);
IF FILE.EXISTS(PicFileName) THEN BEGIN
F1.OPEN(PicFileName);
F1.CREATEINSTREAM(MemStream);
RecItem.reset;
RecItem.Setrange("No.","Item No.");
if RecItem.FindFirst then
begin
RecItem.CALCFIELDS(Picture);
RecItem.Picture.CREATEOUTSTREAM(OStream);
COPYSTREAM(OStream,MemStream);
RecItem.MODIFY;
End
F1.CLOSE;
END;
Please check and modify the code as per your requirement.
Regards,
Diwakar
there is one line in the image table...
Image Name: BF2T Y
Path: c:\user\Pictures\
Item No: BF2T Y
the image is a small .jpg file
PicFileName:= STRSUBSTNO('%1%2.jpg', Path,"Image Name");
IF FILE.EXISTS(PicFileName) THEN BEGIN
F1.OPEN(PicFileName);
F1.CREATEINSTREAM(MemStream);
RecItem.RESET;
RecItem.SETRANGE("No.","Item No");
IF RecItem.FINDFIRST THEN BEGIN
RecItem.CALCFIELDS(Picture);
RecItem.Picture.CREATEOUTSTREAM(OStream);
COPYSTREAM(OStream,MemStream);
RecItem.MODIFY;
END;
F1.CLOSE;
END;
When I run the report I get an error:
"Filter could not be applied. Could not apply filter "B1 G" to column no. "1" because the field is missing or unavailable."
Could this be a permission issue, that it is unable to access the path on my pc (Win10Pro)? I'll play with it tomorrow night.
Diwakar - thank you so much for your assistance
Regards,
Diwakar