Trying to configure a pop-up to remove all of the fields with no data since the list is very long. I tried using IsEmpty but they are still there. Any help is appreciated.
This is a sample popup
Thanks, I'll change the H3 and see how that goes. That's a bummer (and a little annoying) on the expression part.
I think I have what I need now, subject to a few minor changes after feedback from our users. Thanks again for all of your help and for sharing the code. It is greatly appreciated and things went much faster after you responded.
Glad to help!
I just need to create a new Arcade expression under my pop-up properties box, add the above and change to my fields?
That's right! You can think of the two variable fieldsArray and labelsArray as matched pairs. The fieldsArray values need to be the actual database field names, then you can alias them (like you would do from the field menu in map Viewer), just making sure that the label is in the same order as the field name.
Of course, you'll also have to adjust the HTML. This part of the code:
var returnString = `<h3 style="background-color:${backgroundColor};padding-left:2%">Ramp Info</h3><table style="width:100%;background-color:#f4f4f4;">`;
wont work for you because it's relying in my backgroundColor variable, which is based in the field "Condition."
You cane remove this portion:
var cond = $feature.Condition
var backgroundColor = When(cond=="1 (Non-existant)","#fc461d",cond=="2 (Poor)","#df750c",cond=="3 (Functional)","#f2cc0d",cond=="4 (ADA Compliant)","#37aac4","#cccccc")
and then just remove everything after "h3" in that tag.
I added this and just used 2 fields to test. I don't see anything different in my popup. It's still showing Afghan which is empty and that's what I don't want to show.
I see a couple things which could be tripping you up. Your text string starts with an <h3> tag, but doesn't have a closing tag. Try adding text followed by a close tag just to see what happens:
var returnString = `<h3>This is my popup title</h3>
Next, are you using the Arcade popup element (as opposed to text popup element or an arcade expression)? This format of Arcade will only work using the Arcade popup element.
I want to use domain names in the return string, is that possible?
I want to use domain names for one field in the return string, is that possible?