Display a picture if a condition is true in a template

Hello everyone !

I have a question about the expression in template.
I want to display a picture if a condition is true.
I have try this expression :
<<IFS([Lot accepted or rejected]="Lot accepted", "Picture/green_rond.png","Picture/red_rond.png")>>

On my report I only see the link of my picture but not my picture... Can someone help me to resolve this problem ?

0 6 297
6 REPLIES 6

I think the correct expression is:

<<IFS([Lot accepted or rejected]="Lot accepted", SNAPSHOT("Picture/green_rond.png"),SNAPSHOT("Picture/red_rond.png"))>>

I tried your solution and I have this picture displayed 

 

Laurine_0-1661396453399.png

I tried to put the google link and the file link and for both of the case : it doesn't work..

 

For templates, the suggestion is that you should use Template If statements.

Use If expressions in templates - AppSheet Help

Basically:

 

<<If:(1=1)>>
# This is going to be inside the report because 1 equals 1 so 1=1 is true
<<EndIf>>
<<If:(0=1)>>
# This won't be on the report, you know why
<<EndIf>>

 

Now, about the picture, I don't think any relative path will render as an image.
You need to refer to an image column in order to insert images in your report. This should be easy if you create a table just for the sake of using them on templates

Thank you for your reply,

I created a table specifically to list my images. Only I don't know how to retrieve the images that interest me in the table.
Imagine that the image that interests me is in line 5 of my column, I would have an expression of this type?
<<IFS([Lot accepted or rejected]="Lot accepted",Pictures[Link][5] , Pictures[Link][4])>>

Ok, I understand why you would think that would work but that's out of any AppSheet syntax. Try to master the expression list, that will help you a lot.

Whatever, I suggest you to change it a bit (I mean, don't check the index of the item, eventhough there is a function for that), since if for some reason the row is not the same in the future, things could brake. Instead of refering to your row number/index, use another value. For example, a column called [Usage]. If the [Usage] column is aproval, you would do something like this:

<<If:[Lot accepted or rejected]="Lot accepted">>
LOOKUP(
 "Aproval", # The value you are looking for
 "TemplateImage", # The table/slice
 "Usage", # The column where the value should be
 "Image" # The returned value from the table/slice
)
<<EndIf>>

 

Thank you I found the solution with the LOOKUP expression ! 

I write this expression :

<<IF ([Lot accepted or rejected]="Lot accepted", LOOKUP("Green dot","Pictures","Title","Link"),LOOKUP("Red dot","Pictures","Title","Link"))>>

Top Labels in this Space