Importing 1000 images in Item table in NAV 2013

diwakar_143
Member Posts: 5
Hello Everyone,
I want to import 1000 images in Picture(Blob) field in Item table via processonly report.
The images names are same as Item no. with .bmp format.
I want to import 1000 images in Picture(Blob) field in Item table via processonly report.
The images names are same as Item no. with .bmp format.
0
Comments
-
Welcome to Mibuso
You can try these suggestions
http://www.mibuso.com/forum/viewtopic.php?f=23&t=15070
http://dynamicsuser.net/forums/p/32976/173139.aspx0 -
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.0 -
Hello Mr. Mohana,
I had already tried this,but IMPORT function is not working in NAV 2013.I want to do this process in NAV 2013.0 -
-
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.0 -
Create a report with Item as a dataItem
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;0 -
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.
Thank you0 -
Hi Normajm,
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,
Diwakar1 -
Thank you Diwakar. I haven't had a chance to try this, been tasked with a different project. When I get back to this, will follow up with my results.0
-
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.0 -
That was a the issue! I set up a folder on the root of the NAV server and ran the report from there. Pictures populated the items as needed.
Diwakar - thank you so much for your assistance0 -
You are welcome.
Regards,
Diwakar0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions