How can i import images base on a naming convention. Each image name is the primary id for the employee. All these images will be stored on a directory and what i want to achieve on navision is to click a command button and then all images will be imported for the respectively employee and if the picture for an employee is not found it should be a message allowing the user to manually import the picture,...
Thanks
0
Comments
Don't forgett, NAV can only display bitmaps.
Don't forgett, that is it not a good idea to store big pictures in the table because it's bad for the performance (for this theme exist a lot of topics here).
So, that your pictures are stored in a directory is not so bad.
You can store the UNC path (also for this exist topics here) and the filename + extension.
If a user need to display this image open it with running open the image self with, for example, "Paint" or the default application for bmp.
With this you have also the posibility to store all image type and not only bmp.
viewtopic.php?f=23&t=25060
onaftergetRecord Trigger add the following code.
Picture.import('c:\pictureFolder\'+"No."+'.bmp',false);
Modify(true);
Run the report. change the pictureFolder to correct directory.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
something like import pics for all employees that don't alreay have a pic....
OnAfterGetRecord
Damn you guys are quick
http://www.BiloBeauty.com
http://www.autismspeaks.org
and change
to
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
90000 empoyees and for everyone, or for every second / 3rd a large bitmap?
Do you need really all 90000 empl. for example for "Wage and salary"
If yes don't import the bitmaps, use the solution with the UNC path.
I bet you, by next year the employees will increase. These database handles the social security system of our country. Not all employees are registered for that matter.
Fill in the UNC path in into field.
On the employee card add the field and add a button called Open.
OnPush trigger of the button add
Hyperlink("Picture location");
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
There are many posts about importing pics on the fly when you need to view them - but it doesn't get stored in Navision. They stay on a seperate drive or in your case sounds like you need a seperate Picture server that back's itself up.
then map a drive to that server.
You basically have a picture box - sourceexp = Picture
OnAfterGetRecord()
SETRANGE("No.");
CLEAR(Picture);
CALCFIELDS(Picture);
IF EXISTS ('YourDrive:\YourDirectory\'+"No."+'.BMP')
THEN Picture.IMPORT('YourDrive:\YourDirectory\'+"No."+'.BMP',FALSE);
I would add another code OnModify of the table to insure the pic doesn't get saved.
because the pic is in "picture" as you're viewing it. If a modify happens while it's there in mem - it will get saved.
So you want to drop the ax on the save pf the pic by clearing the boolean.
CLEAR(Picture);
Hope that made sence - i'm a bit tired
http://www.BiloBeauty.com
http://www.autismspeaks.org
Becasue NAV select ever the Lenght of the Blobfield if there is a blobfield in the database.
So, if you have datas in the BLOB field, the SQL server must run some internal operations to get this datas.
And it's not sure, that these datas are in the same page area (read books online to get more infos about how the server stores the data [8k page, Block (8 Pages)]. The BLOB self is not in the page of the data self. If you use BLOBs the sql server only use 16Bytes for a "Link" to the BLOB pages self. So, the server must read all this pages.
This you can see with the SQL profiler and with the indicator "Reads". And also doen't forget. Every one "READ" mean, that the sqlserver must read a 8k page. So if you have a Read of 25697, the server must load 25697 * 8K = 205576 KB = ~ 200MB in the RAM of the server! And Navision send ever a select *, DATALENGTH(BLOBFIELD)! Also if you open a card form, if you open a list form, if you run a report or if you post a record or read arecord during a process that contains BLOB fields.
So, i'm sure you doesn't need this perfomance bottlenecks ;-)
Store the images separate in the network and save in your dataabse only the UNC path and extension.
So you can also use gif, jpg, png, bmp, pdf, etc and not only bmp and the database will not increase. In server 2008 there is a new "feature" for this. Here you can also say, that the BLOB should be stored in the network and if you make a backup of the database the sever also backup the BLOB files.
If you really need the datas in the database, please doen't store this datas in the BLOB field of the "main" table (here employee). Use as "workaround" a table like: EmployeePictures with the PK field of the table employee and a BLOB field. In this table you sore the pictures. And only if you need to see the pictures you open a form / report that get this datas from this table. So all other "precesses" over the empoyee table doesn't read this table because u doesn't use it and you have no performance trouble ......
It's only a idea but i'm sure it's better than storing the data directly in the "maintable".
Regards