if statement on custom File Direct uploader field

Duncan Koza asked on January 3, 2020 23:59

I would like to write an if statement that will execute some code only if two fields are empty. My users can upload two images via two separate direct upload fields. The field names are Image01 and Image02.

I tried to write this but it didn't work:

{% If (Image01 != "" && Image02 != "") { "HTML CODE Goes Here" } %}

Does anyone see what I might be doing wrong?

Recent Answers


Brenden Kehren answered on January 4, 2020 00:37

If this is on the field definition, then you need to use Image01.Value.

1 votesVote for this answer Mark as a Correct answer

Duncan Koza answered on January 6, 2020 16:43

I tried {% Image01 %} and the following is returned 428b6d1b-9ecb-4baf-ab58-828b8e8515ff

When I try {% Image01.Value %}, nothing is returned.

When I want to display the image that was uploaded, I have to use this code: {% GetFileUrlByGUID(Image01, "" ) %}

But right now, I just want to check to see if there is an Image01 and an Image02. Because, if both are null, then I want to do something. Any Thoughts?

0 votesVote for this answer Mark as a Correct answer

Duncan Koza answered on February 3, 2020 16:10 (last edited on February 3, 2020 16:13)

I figured it out. This code wasn't to go on the field definitions but on a repeater web part, in a transformation. Not sure is this is the best way, but the following worked. I had to make some variables (bImage01, bImage02 and bImageVal). Then I checked against them.

{%
  bImage01 = IfImage(Image01,"True","False");
  bImage02 = IfImage(Image02,"True","False");
  bImageVal = "";
  If(bImage01 == "True" || bImage02 == "True") {bImageVal = "True"} else {bImageVal = "False"};

  If (bImageVal == "True") { %}

  HTML CODE GOES HERE

  {% } #%}
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.