I am attempting to create a conditional arcade expression that will list all of the fields that do not have a null value with an individual label and not show the field at all if the field is null. My current expression is below.
if (IsEmpty($feature.ABARTA_WI)){
return ""
} else {
return "Abarata: "+$feature.ABARTA_WI
}
This expression works in that it does not show the label or null value, but in the ArcGIS Portal pop up, it leaves an empty line for each one that is null, and i need it to not be there at all so the pop up is clean. As you can see below, this is creating empty lines in the popup.
I would prefer the popup to display something like below, eliminating the empty lines.
Chief: 0.28
Chief WI MKR: 0.28
Enerplus: 0.3
arcade expression arcade pop-upsconditional pop ups
Any help would be greatly appreciated.
Thank you
You can, but it will require multiple expressions and some html to do this (if you want to show it using html). Or you can create a larger expression that constructs the text to display and omits empty values.
Well I need this popup to look professional so this is what i need to do. Can you provide further information on what that larger expression would look like?
Using something similar to what you have, you could use an approach like this.
{expression/expr1}
var a = $feature.notes
var b = $feature.popper
var attributes = ""
If (!IsEmpty($feature.notes)){
attributes = a + TextFormatting.NewLine + b
}
else {
attributes = b
}
return attributes
If Feature notes attribute is not Empty Show both attributes.
Else show one attribute
Mark
I was looking all over for a solution that I could only display non null field values with the field alias and ended up combining a few different things I found.
var features = FeatureSetByName($map, 'CTP_Roadway_Observations', ['*'], false);
var aDict = Schema(features);
var aArray = aDict["fields"];
var output;
for (var i in $feature){
if (!IsEmpty($feature[i])) {
for(var j in aArray) {
var dict = aArray[j];
if (dict['name'] == i){
output += dict['alias'] + ": " + $feature[i] + TextFormatting.NewLine + TextFormatting.NewLine;
}
}
}
}
return output;
Produces this:
Thanks for this, its got me part way there 😊. However I noticed that it changes the order of the fields, is there a way to display it as per the schema order?
Take a look at this blog on how to customize your popup: https://community.esri.com/community/gis/web-gis/arcgisonline/blog/2017/07/18/conditional-field-disp...
Apart from the post mentioned by Ken, there are some comments that will be relevant for you:
UPDATE!!
This is a confirmed bug, and the arcade script will not produce the results we are asking for. This bug is not repaired until the 10.7 license level.
Can you share the number of the bug and the description?