It's been discussed how to save your Item pictures on an outside drive and show them in Nav on the fly as BMP. This way you Database doesn't grow out of control when you have to import 10000 pics into BLOB fields.
You can also have JPG pics on an outside drive and show them in Nav.
To Test use Form 346 item Picture
OnAfterGetRecord add
SETRANGE("No.");
IF EXISTS ('P:\jpg\'+"No."+'.jpg')
THEN BEGIN
ConvertPic:= SHELL('i:\navision attain\jpg2bmp.exe -outfile c:\temp.bmp -color 256 -bmp -scale 1/1 p:\jpg\'+"No."+'.jpg');
Picture.IMPORT('c:\temp.bmp',FALSE);
END
ELSE BEGIN
CLEAR(Picture);
END;
ConvertPic Type Integer
i:\navision attain\jpg2bmp.exe //is the drive & directory of the EXE that I used, which you can find here:
http://www.mibuso.com/dlinfo.asp?FileID=70'P:\jpg\'+"No."+'.jpg' //is the directory we keep our JPG pics (P:\jpg) Also the pictures are named as it's Item Number hence the "No."
But you could easily change it to UPC or Vendor Item No if that's how you name your pics.
I have set the SCALE to 1/1 but the other choices are
half = 1/2
quarter = 1/4
eigth = 1/8
this will reduce the pic size.
Most pc's are fast today and the EXE file flashes it's little Dos box for an instance - I forgot the command that makes that invisible running behind the scenes. Perhaps stuffing it into a BAT file. anyway...
Comments
Any ideas, suggestions?
EDIT: if i execute same command from cmd line, it succeeds.
Dynamics NAV Enthusiast
@Tomas : probably you need to put some parameters between double quotes.
[Topic moved from Navision Attain forum to Navision Tips & Tricks forum]
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
The only issue left is that if we put images (and jpg2bmp.exe) on a shared drive, everytime we'll display image, we'll have to cofirm that we trust that program.
Otherwise, thanks Savatage and kriki for a wonderful tip! \:D/
Dynamics NAV Enthusiast
http://www.BiloBeauty.com
http://www.autismspeaks.org
Hmnz,
No. I am running on Windows XP. I have copied exe file to other computer and mapped a new drive for that folder. Each time I want to open Item Picture form I get Open File - Security Warning:
Dynamics NAV Enthusiast
Perhaps if you save the jpg2bmp.exe from your client folder or a drive on your PC instead of having the program on a network drive - it will not think it's an outside program every time.
http://www.BiloBeauty.com
http://www.autismspeaks.org
Yes, but this means, that you need to copy same program to all user machines, instead of placing it somewhere in the network in one place. :?
Dynamics NAV Enthusiast
If you have 10 machines then it's not a problem
you have 100 then ouch!
http://www.BiloBeauty.com
http://www.autismspeaks.org
I'ved solved this problem, it was an other progamm (DLL), as following:
I've stored my dll (which i needed on ever client pc) into a BLOB in a special table. When the user want's to run the Navision Object which need my DLL i checked before if this DLL is registerd (for example in table Automations) if it is not reg. i extract it from the BLOB to an defined folder and regist. it with regsrv / regasm. So the users can use my DLL /or others on every PC. The admins doesn't need to install this when they setup a new PC.
the same principle u can use for this problem .....
Regards
René
http://www.mibuso.com/howtoinfo.asp?FileID=5
http://www.BiloBeauty.com
http://www.autismspeaks.org
An other idea is, when you not will map the network drives, that u use the UNC path. For using UNC here in the forum are some examples.
As an admin you can install a dll onto every machine in the network using the psexec tool from MS (www.sysinternals.com will take you to the correct page).
Two commands will do the trick and you can probably do it with one.
psexec \\* copy \\fromserver\fromshare\fromdll.dll c:\windows\system32\todll.dll
psexec \\* regsvr32 c:\windows\system32\todll.dll
psexec \\* executes the command on every machine in the network.
Ian
I am new to navision but i tried the code given by Thomas. but when i compiled I got some problem ](*,)
1. Unknown Variable Wshell :-k
I can define this in Global but what is the data type is it a function?
2. Cmd unknown variable
And I have some more doubts where is this Windows Style: = 0; defined is it a property?
[-o<
Wshell->Datatype=Automation->Subtype=Windows Script Host Object Model->WshShell
I assume CMD is type integer
http://www.BiloBeauty.com
http://www.autismspeaks.org
We're using the code below in form 30 (Item Card), and that works great.
We only encounter one strange problem. If a user keeps pressing the navigate buttons (Back or Forward) in the toolbar, a Navision messagebox pops up stating "Do you want to change the name of the record? (Yes - No)". This occurs just before a record that contains a picture is displayed. The result is that the previous item now shows the image which is wrong.
So what might be the problem regarding the messagebox and showing the image one record to early?
Hope someone has an answer.
Nico Dekker
The Netherlands
Which trigger to you have the code on? if I get a second I'll try your code and see what my results are.
http://www.BiloBeauty.com
http://www.autismspeaks.org
When i run this function then i found ole error
Microsoft Dynamics NAV
This message is for C/AL programmers:
An exception was raised in method Run. The OLE control or Automation server has returned error (HRESULT) -2147352567.
The component did not provide the exception description.
OK
now what i do
Thank's !!!
Devendra
Cmd = Integer
WindowsStyle = Integer
WaitForCommand = Boolean
What do you have these declared as?
http://www.BiloBeauty.com
http://www.autismspeaks.org
Cmd = Text 250 and it works
Further I did generated temp.bmp in user level temp folder to avoid multi user conflict (Here the jpg name was based on "Design No." and there were multiple item with same design no. )
- Rajesh Asar
TVision Technology Ltd
An exception was raised in method Run. The OLE control or Automation Server has returned error (HERSULT) -2147352567.
Can anyone please help.
http://www.BiloBeauty.com
http://www.autismspeaks.org
I have tried this technique to import the jpg file but the problem is the photo is not converted. i have taken "cmd" variable as text 250 because whenever i choose the datatype of this variable as integer, the error appears for the datatype "integer := text". the photo i have chosen is not converted to bmp. please suggest me where am i wrong??
Path := 'D:\';
WindowsStyle := 0;
WaitForCommand := TRUE;
SETRANGE("No.");
IF EXISTS (Path+"No."+'.jpg') THEN
BEGIN
CREATE(Wshell);
cmd := Path+'jpg2bmp\jpg2bmp.exe -outfile'+Path+"No."+'.bmp -color 256 -bmp'+Path+ "No."+'.jpg';
Wshell.Run(cmd,WindowsStyle,WaitForCommand);
CLEAR(Wshell);
Photo.IMPORT(Path+"No."+'.bmp',FALSE);
END
ELSE BEGIN
CLEAR(Photo);
END;
http://www.BiloBeauty.com
http://www.autismspeaks.org
Looks like you're missing the spaces, you do have to be precise for this to work.
You can use a MESSAGE to popup the cmd that's being used and copy&paste that into a cmd shell to check.
TVision Technology Ltd