If Else Statement

265
1
Jump to solution
07-07-2022 11:59 AM
by Anonymous User
Not applicable

We have a string field in survey123 titled Activity Notes.  If the field is empty, we do not want anything displayed.  I cannot get it to work. Error is Unable to execute Arcade script. I am creating this in the list widget. Thank you for any help. Annette

returnstring = $datapoint["activity_notes"]

if (IsEmpty(returnstring)) {
return "";
} else {
return returnstring;
}

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Hi Annette!

In a Dashboard's Advanced Formatting, the returned object always needs to be a dict with attributes.

What you can do is put the returnstring into the output attributes object. Items in this can be referenced using the format {expression/attributename}. Like this:

return {
   attributes: {
    returnstring: $datapoint["activity_notes"]
   }
}

And in your list item template, put {expression/returnstring} in there, and the attribute will show up.

As an added bonus, when that expression is on its own line in your list item template, the line will not even display if the attribute is empty.

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

Hi Annette!

In a Dashboard's Advanced Formatting, the returned object always needs to be a dict with attributes.

What you can do is put the returnstring into the output attributes object. Items in this can be referenced using the format {expression/attributename}. Like this:

return {
   attributes: {
    returnstring: $datapoint["activity_notes"]
   }
}

And in your list item template, put {expression/returnstring} in there, and the attribute will show up.

As an added bonus, when that expression is on its own line in your list item template, the line will not even display if the attribute is empty.

- Josh Carlson
Kendall County GIS
0 Kudos