Display an image based on a variable

Check the value of a variable and display the image specified by the variable.

For this example, all images are contained in /images/database, which is in the same directory as the report design document. The data source includes the field orderline.product.prodpic, and the field is a STRING.

In the Image Box, for the Location property, you enter the following expression:

Tip:

It is good practice to use the trim() function to remove extra whitespace from a string expression.

"/images/database/"+orderline.product.prodpic.trim()

This expression evaluates to a STRING value that specifies the image to be displayed.