Help eliminating empty lines in a custom pop-up using Arcade

3260
6
Jump to solution
04-24-2020 06:50 PM
LynnCarlson__GISP
Occasional Contributor

I have created seven Arcade expressions in order to customize a pop up on a hosted feature layer in ArcGIS Online.

Each expression uses IIF to create the text I want to appear in the popup.

Example: if the feature has an attribute trainassist = 'yes', I have the text in the popup say "Training and Assistance"

so my expression consists of:

IIf($feature.TrainingAssist=="yes", "Training and Assistance", " ")

if that same feature has a second attribute combat = 'yes', I have the text in the popup say "Combat"

IIf($feature.Combat=="yes", "Combat", " ")

There are a total of seven attributes that I do this for.  If an attribute doesn't have "yes", I don't want any text to appear, so the else is just " ".

The trouble happens when I create the custom pop up using the Custom Attribute Display.

Simply listing the expressions one after the other results in empty lines in the popup  (the else " ") when the condition of 'yes' is not met. 

I've tried building one combined expression with IsEmpty, and making an array variable, but I am stuck.

I've attached another graphic which goes into further detail.

Thank you in advance for any help!

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor
6 Replies
XanderBakker
Esri Esteemed Contributor

Hi Lynn_Carlson , 

One simple way of doing this is to include a new line in the formula and put the expressions on the same line in the pop-up (see sample below for the expression):

IIf($feature.TrainingAssist=="yes", "Training and Assistance" + TextFormatting.NewLine, "");

What this will do, is that when you want something to return it will return the text and go the the next line. 

XanderBakker
Esri Esteemed Contributor
LynnCarlson__GISP
Occasional Contributor

Thank you so much! 

On my first foray into GeoNet searching for an answer, I did not find your document.  After I went back and dug a little more, I did find it, but hadn't had a chance to get back on and update my own question before you answered.

Anyway, this is very helpful and I am making some great headway now.

Sorry I posted this without finding the answer the first time around.

XanderBakker
Esri Esteemed Contributor

Hi Lynn Carlson, GISP ,

Don't worry, it sometimes is difficult to find the right post since descriptions may be different. One way of making useful posts easier to find is to mark them helpful or if they answer the question to mark them as the correct answer. 

If you run into problems you post them back here and I will get a notification.

XanderBakker
Esri Esteemed Contributor

Hi Lynn Carlson, GISP ,

Just a minor request: could you mark the post that answered your question as the correct answer? Now it looks like you answered your own question and that answer may not be the information other users are after to solve similar situations.

Thanks! 

0 Kudos
JohnBickmore
New Contributor III

TextFormatting.NewLine works great when I configure my popup in a webmap, however when I use that layer in a dashboard the newlines seem to be ignored and everything is put back to one long string?

0 Kudos