Conditional field display in arcade pop-ups

1508
1
07-21-2020 11:26 AM
JoeLivoti
New Contributor III

I am having trouble with this. I have scoured the blogs concerning this issue and admittedly am very new to arcade and would appreciate any help. I may be trying to do too much.

I have a layer with several different permit inspections within it (43 to be exact with 5 fields each). I would hope to not have to do the same thing 215 times but if i need to, I shall. What I am trying to do is to only show the fields that have a value. This I can do, 215 times if needed. I would like to be able to group them and have a header if there is a value in a field and for there not to be blank space in between. 

This is what I have currently (am currently only working with one inspection until i have it figured out).

My arcade:

IIF(isEmpty($feature.notes14), "", "Footer") This ideally would be an expression that returns the below set if status14 has any value (or anyone of the predfined values of inprogress, approved, or notapproved with a header of footer
IIF(isEmpty($feature.status14), "", "Status")
IIF(isEmpty($feature.assignedto14), "", "Inspector")
IIF(isEmpty($feature.other14), "", "Other Inspector")
IIF(isEmpty($feature.date_approved14), "", "Date Approved")
IIF(isEmpty($feature.notes14), "", "Notes")

The current attribute expressions:

And the current Pop-up: the red box are fields with no value: would like for there to be no break in between fields with values.

If I can do this in a single block of code for each different inspection, that would be fine. I can easily replace the number and the header.

Thank you in advance for any help!!!

0 Kudos
1 Reply
XanderBakker
Esri Esteemed Contributor

Hi JosephLivoti ,

A solution was provided at this post: Conditional Field display with Arcade in Pop Ups (revisited) (scroll all the way down). To make it easier to find for others, see the answer below:

You can use a single expression which reads out all the information and presents the result. The thing that you can't do is apply any formatting at different parts of the result. In you example you have expression single underlined and all expressions in bold. So, I think it might be better to adjust what you already have.

 

The individual expressions would become:

IIF(isEmpty($feature.status14), "", TextFormatting.NewLine + "Footer")
IIF(isEmpty($feature.status14), "", TextFormatting.NewLine + "Status")
IIF(isEmpty($feature.assignedto14), "", TextFormatting.NewLine + "Inspector")
IIF(isEmpty($feature.other14), "", TextFormatting.NewLine + "Other Inspector")
IIF(isEmpty($feature.date_approved14), "", TextFormatting.NewLine + "Date Approved")
IIF(isEmpty($feature.notes14), "", TextFormatting.NewLine + "Notes")
IIF(isEmpty($feature.status15), "", TextFormatting.NewLine + "Foundation")
IIF(isEmpty($feature.status15), "", TextFormatting.NewLine + "Status")
IIF(isEmpty($feature.assignedto15), "", TextFormatting.NewLine + "Inspector")
IIF(isEmpty($feature.other15), "", TextFormatting.NewLine + "Other Inspector")
IIF(isEmpty($feature.date_approved15), "", TextFormatting.NewLine + "Date Approved")
IIF(isEmpty($feature.notes15), "", TextFormatting.NewLine + "Notes")

...and the text in the pop-up would become a single line like this:

{expression/expr5}{expression/expr0} {status14}{expression/expr1} {assignedto14}{expression/expr2} {other14}{expression/expr3} {date_approved14}{expression/expr4} {notes14}{expression/expr6}{expression/expr7} {status15}{expression/expr8} {assignedto15}{expression/expr9} {other15}{expression/expr10} {date_approved15}{expression/expr11} {notes15}

 

In case a field is empty the expression will detect it and return an empty string which you wont see and which does not take up an empty line. 

0 Kudos