Open Forum

Expand all | Collapse all

Missing External Pictures in Report

  • 1.  Missing External Pictures in Report

    Posted 11 days ago
    Hi Everyone,

    If this questions isn't for here, I'm sorry.

    I have a custom report built using Visual Studio 2013 with an image that is located in an external folder. I have the image source set to external and the expression is ="File:\\CPP-BUR-FIL01\users\NAV Attachments\Item Pictures - Outer Cartons\" + Fields!No_Item.Value + ".jpg" where the bold text is the file location and the italic text is the dataset result that the image file name is named after.  This all works fine and I get the image on the report.
    BUT
    If the image is missing from the folder I get a horrible red X.  Does anyone know of a way to either hide this, or replace with a default image if the file is missing.  I have tried hiding the image using Iif(the file ="",TRUE,FALSE), but as it's external there is no dataset.value to return true or false.  All the web help I can find seems to be from years ago, and doesn't work.
    Any help greatly appreciated.
    Many thanks.

    ------------------------------
    Adam Jones
    Celebration Packaging Ltd
    Burton upon Trent
    United Kingdom
    ------------------------------
    Academy - Online Interactive Learning from Experts


  • 2.  RE: Missing External Pictures in Report

    Posted 5 days ago
    Hi Adam,
    I changed Sales Quote/Order report, to print item picture for each sales line (you can use same principle for any other use)
    Note: all images must be BMP format
    - create a Text Constants called PathToBmp with value \CPP-BUR-FIL01\users\NAV Attachments\Item Pictures - Outer Cartons\
    - create a variable pict, in my example, where pict is Record - TempBlob
    - add picture box to Sales Line section. Set SourceExpr as pict.Blob
    - add this:

    Sales Line - OnAfterGetRecord()
    IF EXISTS(PathToBmp + "No." + '.bmp')
    THEN pict.Blob.IMPORT(PathToBmp + "No." + '.bmp',FALSE);

    Optional, you can add "ELSE pict.Blob.IMPORT(PathToBmp + 'noimage.bmp',FALSE);" if you need to show another image for not found items
    In my case, images are saved as itemno.bmp


    ------------------------------
    Gabriel Kertesz
    International Wholesale
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 3.  RE: Missing External Pictures in Report

    Posted 5 days ago
    Hi Gabriel
    Thank you for getting back to me, can I ask what version you are running please?  We are on NAV2017 and I don't think TempBlob or the IMPORT function are available any more.
    Many thanks.

    ------------------------------
    Adam Jones
    Celebration Paper & Plastics Ltd
    Burton upon Trent
    United Kingdom
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 4.  RE: Missing External Pictures in Report

    Posted 5 days ago
    Adam,
    I'm using NAV 2009, but I believe blob.import is still around, see article posted recent (10/01/2020)
    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/blob/blob-import-method

    ------------------------------
    Gabriel Kertesz
    International Wholesale
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 5.  RE: Missing External Pictures in Report

    Posted 4 days ago
    Hi Adam,

    I am on NAV 2017 as well and confirmed that the TempBlog table does exist as well as the blob.import function so Gabriel's approach may work for you as well.

    I took a similar approach that you did and to get it to work I created a boolean variable as well as a DotNet variable for System.IO.File from which I used the Exists function to check if the file exists:
    FileExistsBoolean := DotNetFile.Exists(ImagePath);

    Once I had the boolean to determine if the file exists or not I passed that over to the report designer and set the "Hidden" expresssion to:
    =NOT(Fields!FileExistsBoolean.Value)

    I am using SQL Server Report Builder instead of Visual Studio but I believe this should translate over. This worked for me to hide the red x.

    ------------------------------
    Jonathan Kleist
    NAV Administrator
    Gustavo Preston
    Chelmsford
    ------------------------------

    Academy - Online Interactive Learning from Experts


If you've found this thread useful, dive deeper into User Group community content by role