ER: Add product image to your Business documents

It is a common ask to show product image details on sales invoice or delivery note documents. In this post I will walk you through the steps to achieve that.

There is a great tutorial on how you can embed image to the ER documents here that I have used as a base to create this post.

As usually, we have to make changes to the standard model, model mapping and format supplied by Microsoft.

Before we start, make sure that you have “Enable usage of EPPlus library in Electronic reporting framework” feature disabled, because it has a bug that does not repeat the image in the report for each line.

I have based my example on sales packing slip, but you should be able to repeat same exercise with any other report.

Import report format, model and model mapping from LCS

I have loaded standard report format from LCS for the sales packing slip (Sales order packing slip (Excel)). Together with the format, Waybill model and Waybill model mapping were loaded:

ER_ProductImage_LCSModel

Create derived configuration for Waybill model

The article I pointed out in the beginning of the blog says that we have to add a field with Container type that will be used to display an image. Therefore, we have to modify Waybill model to include it.

To do this, I have created derived model “Waybill model Contoso”:

Then, I have added ItemImage field under: SalesPackingSlip /Shipment/GoodsItems/Item

ER_ProductImage_CreateContainerFieldER_ProductImage_ItemImageContainerField

We have finished with the changes of the model and can mark it as Complete.

Create derived configuration for Waybill model mapping

On this step we have to map “ItemImage” field added above with the data model. I have created derived configuration and named it “Waybill model mapping Contoso”. When you do this, make sure that you select newly created model!

Click the Designer button and open designer for the SalesPackingSlip:

ER_ProductImage_SalesPackingSlipModelMapping

You should see there, in the data model area, field ItemImage added previously:

ER_ProductImage_ModelMappingDesigner

To map it with the image you should use the following formula:

To display image from Product:

@.'>Relations'.InventTable.'Product()'.'<Relations'.'<Documents'.'getFileContentAsContainer()'

To display image from Released product:

@.'>Relations'.InventTable.'<Relations'.'<Documents'.'getFileContentAsContainer()'

The example in this post is based on the Product image.

ER_ProductImage_ItemImageFormulaDesigner

We have done all the changes here and ready to mark the model mapping as Complete.

Create derived configuration for report format

I have created derived format “Sales order packing slip (Excel) Contoso” that is based on “Waybill model Contoso” we created before.

I have made these changes through Business documents workspace (Organization administration > Workspaces > Business document management, Click New document).

ER_ProductImage_BDMWorkspace

Select line with Sales order packing slip (Excel) and click Create document:

ER_ProductImage_BDMCreateNewTemplate

Enter new format name:

ER_ProductImage_BDMSetDocumentName

The report design was loaded; we have to do few changes to the format which are: add a new cell for product image and add a picture component to this cell. Make sure that the picture is anchored to the top left corner and fits to the cell borders.

Open the template in Desktop app (you can edit it in the online version as well):

ER_ProductImage_OpenInDesktop

Then, add new cell, next to the Item number field, made it wide enough for the image. This cell should be a part of the line range from the report template:

ER_ProductImage_ExcelAddCell

ER_ProductImage_ExcelRange

Add a picture placeholder to this cell:

ER_ProductImage_ExcelAddPicture

Set picture properties in the excel template (Right click > Format picture) to be as below:

ER_ProductImage_ExcelFormatPicture

In the format, check that you have right model mapping specified to refer to the mapping model we created initially:

ER_ProductImage_FormatDesignerMapping

ER_ProductImage_FormatDataSourceProperties

Bind Picture placeholder with the ItemImage field:

ER_ProductImage_FormatDesignerBindImage

Mark the format as complete to proceed with further setup.

Setup electronic report destination

Create a report destination for our format (Organization administration > Workspaces > Electronic reporting > Electronic reporting destinations):

ER_ProductImage_ERDestination

Setup Print management

Configure print management to use our report format (Accounts receivable > Setup > Forms > Form setup > Print management):

ER_ProductImage_PrintMgmtSetup

Done. We have finished with the main setup and it is time to test it.

I have loaded Images for the below products (Product information management > Products > Products):

ER_ProductImage_ProductImage1ER_ProductImage_ProductImage2

Then, I have created sales order and posted packing slip for it. We can run the report and check the results:

ER_ProductImage_RunReport

Sales packing slip report looks as follows:

ER_ProductImage_ReportFinal

One more requirement we can cover with out of the box solution. How cool is that!

2 thoughts on “ER: Add product image to your Business documents

  1. Hi Nataliia,
    Thank you for that again great post.
    I tried to reproduce everything, but I had my difficulties and I got stuck with three errors in my report configuration or report model mapping. It concerns a Case formular with the Enums WMSFreighted By Carrier, Recipient and Shipper. I have no clue what happens here, but I made a detailed documentation in a WORD file, which I would like to send to you by e-mail. But I do not have your e-mail address 😦

    Like

    1. Hi Juergen,
      On the step where you mapped report format to the new model you have to follow same steps for Enum and set model to Waybill model Contoso. Try it and let me know how it goes.

      Like

Leave a comment