item images

Navi_LearnerNavi_Learner Member Posts: 356
Hi, I created a image field with blob data type in one table. When I select item, I can view the picture. My question is how to import images to the system and if it is imported, how to display them in a report? Is there any way to store the images in some other drives not in the current Navision storage locations? Thanks!

Comments

  • krikikriki Member, Moderator Posts: 9,118
    Look at form 346:Item Picture to import a picture.

    In the report, you can copy the picture-box of the form.
    In the OnAfterCurrentRecord, you need to put : CALCFIELDS(Picture);

    It is possible to store the pictures on disk and when needed, you import them on the fly in a BLOB to show them.
    But this takes some coding.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Navi_LearnerNavi_Learner Member Posts: 356
    Thanks! What miximum size of image can be imported?
  • Navi_LearnerNavi_Learner Member Posts: 356
    After the images are imported, how to link the images to a its related items? For the new image field, how to add the image there? Thanks!
  • krikikriki Member, Moderator Posts: 9,118
    Thanks! What miximum size of image can be imported?
    I don't remember if there is a limit. But it has to be a BMP.
    After the images are imported, how to link the images to a its related items? For the new image field, how to add the image there? Thanks!
    Why not import the images in the Item-table? So they are connected without problem.
    Otherwise, you can put the primary key of that table in new fields in the item-table or add in the new table the primary key of the item.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Navi_LearnerNavi_Learner Member Posts: 356
    Thanks! When I use the import form, I can see the images in the form. How can I import the images to the item table? Do I have to create import from dataport? Thanks!
  • krikikriki Member, Moderator Posts: 9,118
    If you can have a file with "item No." and filename (and optionally subdir) of the picture of that item, you can create a dataport to read that file.
    And with Item.Picture.IMPORT("full path to file"); you import the picture.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • SavatageSavatage Member Posts: 7,142
    note: you can still have pics showing without impoting them & increasing your database

    http://dynamicsusers.org/forums/post/1415.aspx

    also you don't need to save a pic in a blob in navision to show it on a report or form

    you can type the location too.

    ex. c:\mypic.bmp
  • Navi_LearnerNavi_Learner Member Posts: 356
    Thanks for your reply! I know how to create dataport to import file before, but I don't know how to import images. In the csv file to be imported, what do I have to input for this field? Secondly if I don't save a pic in a blob, I have to type a location. So I have to type the location one by one. If not how? Thanks!!!!
  • SavatageSavatage Member Posts: 7,142
    the easiest way is to first have your item pics named using the item's number. Ex. If your item # is ABC123 the pic for that item should be named ABC123.BMP (it makes life easy)

    Now if you want them to appear in your item card picture without importing them. Place all the pics in a network folder (I use a folder called "p:\BMP" p for pictures :) )

    On the Item Picture Form

    OnAfterGetRecord()
    SETRANGE("No.");
    
    IF EXISTS ('P:\BMP\'+"No."+'.BMP')
    THEN
    Picture.IMPORT('P:\BMP\'+"No."+'.BMP',FALSE);
    CALCFIELDS(Picture);
    
    That's it - now your pic will show.

    If you want to actually import them into Navision you can create a report to import them all at once.

    Onaftergetrecord you add
    IF Item.Picture.HASVALUE
      THEN
       CurrReport.SKIP
      ELSE
       IF EXISTS ('P:\BMP\'+Item."No."+'.BMP')
       THEN
       Item.Picture.IMPORT('P:\BMP\'+Item."No."+'.BMP',FALSE);
    
    Item.MODIFY;
    

    note P:\ is MY DRIVE you can set it up however you want.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Thanks! What miximum size of image can be imported?

    2Gig.
    David Singleton
  • Navi_LearnerNavi_Learner Member Posts: 356
    Thank you all! I haven't tried it yet, but I will. Actually our images are not related to the the item to our inventory, but to the sales orders. When the customer places orders, he need to send his own graphic. So based on your theory, each picture will be named as sales order number.bmp. Last thing to ask in your code:
    IF Item.Picture.HASVALUE
    Can I write as
    If Sales header.picture.hasvalue
    And what does picture stand for, value, variabl or...? Thanks for all your help?
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Open the Item Table in designer, find field 92 Picture, and copy paste it into your sales header. (you will need to give it a new number.).
    David Singleton
  • Navi_LearnerNavi_Learner Member Posts: 356
    Thank you! I got it. I am testing the report, but field imported is asterisk *, no image at all. Would you please tell me why it happens? Thanks!
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Thank you! I got it. I am testing the report, but field imported is asterisk *, no image at all. Would you please tell me why it happens? Thanks!

    The asterisk comes from a flag in the actual table. The picture is stored in a Blog, and the blob is not actually a part of the Navision table.

    There are two things you need to do.

    1. the Picture filed needs to be the source expression in a PictureBox, it cant be a normal text box.
    2/ Depending how you call the Picture field, you may need to do a calcfields. Its not really a calcfields, it is just telling Navision to get the data from the blob:

    SalesHeader.Calcfields(Picture); // or something like that.
    David Singleton
  • Navi_LearnerNavi_Learner Member Posts: 356
    Thank you David! Yes, the the Picture filed is the source expression of the picture box. This time, I follow your advice and add calcfields, but it still shows asterisk. Thanks!
  • SavatageSavatage Member Posts: 7,142
    1) is your picture saved in a blob field?
    2) is your picture saved outside navsion?
    3) Where did you put the calcfields command?
  • Navi_LearnerNavi_Learner Member Posts: 356
    Thanks! I follows what Savatage's instruction. How to save the picture in the blob field?
  • SavatageSavatage Member Posts: 7,142
    It sounds like a statement but has a question mark at the end. :-k
  • WaldoWaldo Member Posts: 3,412
    If the questionmark was intentional: :wink:
    PictureExists := Picture.HASVALUE;
    IF Picture.IMPORT('*.BMP',TRUE) = '' THEN
      EXIT;
    IF PictureExists THEN
      IF NOT CONFIRM(Text001,FALSE) THEN
        EXIT;
    CurrForm.SAVERECORD;
    

    I copied that code from form 1 after "Picture"/Import menu item OnPush trigger. I think you'll get the "picture" :wink:

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Waldo wrote:
    If the questionmark was intentional: :wink:
    PictureExists := Picture.HASVALUE;
    IF Picture.IMPORT('*.BMP',TRUE) = '' THEN
      EXIT;
    IF PictureExists THEN
      IF NOT CONFIRM(Text001,FALSE) THEN
        EXIT;
    CurrForm.SAVERECORD;
    

    I copied that code from form 1 after "Picture"/Import menu item OnPush trigger. I think you'll get the "picture" :wink:

    Actually Harry alrady posted this code on page one of THIS thread :mrgreen:
    David Singleton
  • WaldoWaldo Member Posts: 3,412
    Oops
    :oops: ... this thread has a page 1 ... :oops:

    Yeah well ... he asked twice, so ... :wink:

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Navi_LearnerNavi_Learner Member Posts: 356
    Thanks! The reason I asked twice is that we can't do any code in the form level because of licence. Since Harry mentioned before we can save files in the network and point to the path in the report, and the picture will be shown out too in this way. I tried, but it doesn't work. To answer Davids' question:
    1) is your picture saved in a blob field?
    2) is your picture saved outside navsion?
    3) Where did you put the calcfields command?
    Yes, all the pictures are saved in a blob field, but can't see the picture except asterisk(still the same question)
    All pictures are saved in a folder of network which are outside of Navision
    Calcfields command are put after OnAfterGetRecord() of salesheader.
    I really appreciate your assistance. Sorry for my questions! Thanks!
  • SavatageSavatage Member Posts: 7,142
    Thanks! The reason I asked twice is that we can't do any code in the form level because of licence.
    .
    .
    .
    Calcfields command are put after OnAfterGetRecord() of salesheader.

    How did you put code in OnAfterGetRecord if your license doesn't allow you??

    Please be clear or this will go on forever.
    -What Table do you have your picture Blob Fields saved in.
    -When you see the "*" it means the blob field is filled.
    -Are these pics BMP's?

    lets start with that.

    Note: The methods mentioned earlier do work you just didn't impliment them correctly.

    Just curious:If the pics you are talking about are related to sales orders why is the title called Item Images?
  • Navi_LearnerNavi_Learner Member Posts: 356
    Thank you for your help, Harry! Here is the anwer to your question:
    How did you put code in OnAfterGetRecord if your license doesn't allow you??

    I put the code in the report of OnAfterGetRecord, not on the form. We have licence in report, but not in table or form.

    -What Table do you have your picture Blob Fields saved in.
    I saved the pictures in a new table created, which has relationship with sales header. I created a new Bolb field in this table.
    -When you see the "*" it means the blob field is filled.
    -Are these pics BMP's?
    Yes, all the pictures are saved with bmp with the file name of the sales order no. After I ran the report, I checked the blob field of the table and found it has * in it. I don't know why this field is filled without anything?
    Thanks!
  • easabanganeasabangan Member Posts: 114
    If the thing you want to achieve is to show the picture on a report.

    Do the following on the report

    1. On the data item property of the report place the name of the field you want to show in the calcfields.
    2. In the report sections place a picture box instead of text box.
    3. on the property of the picture box replace the SourceExpr with the name of the field (blob/picture field).
    4. Save the report.
    5. Then try to run.

    This process works fine with me.

    Hope this helps.
    No future at CPI
Sign In or Register to comment.