AnsweredAssumed Answered

Can I add a conditional statement in Arcade to display one of two FeatureSet script values?

Question asked by adaml on Jan 28, 2020
Latest reply on Feb 19, 2020 by xander_bakker

I successfully used Overlapping Features in Pop-Ups Quick Introduction to Using FeatureSets with Arcade in two separate scripts to combine two surveys with the same feature layer points.  I am getting the results I desire separately.   So now I want to add a third piece and that is a conditional - IF A doesn't exist then return B else return A.  


However I have some code and it is trying to return the entire feature class and I can't seem to pull just one field from the feature class.   (see Script 3)  NOTE: I am relatively new to Arcade so I may be going about this all wrong.


Here are the two scripts that are pulling the info I want:

Script 1: var intersectLayer =Intersects(FeatureSetByName($map,"BowersTransactions"), $feature)


for (var f in intersectLayer){
return f.feno2

Script 2: var intersectLayer =Intersects(FeatureSetByName($map,"BowersInspections"), $feature)


for (var f in intersectLayer){
return f.extinguisherno


Script 3: var inspfe =Intersects(FeatureSetByName($map,"BowersInspections"), $feature)
var transfe =Intersects(FeatureSetByName($map,"BowersTransactions"), $feature)


if (isEmpty(transfe))
{return inspfe;}
else {return transfe;}

Script 3 doesn't error out it tries to display all 20 or so fields.  So it won't allow me to add it to a popup since it is too much information.   I included the result from Script 3.


I thought briefly that FeatureSetByID might narrow this down to one field which is what i want however the little bit of reading I have done on that function seems to indicate that it uses arrays and I am just trying to pull the data from a field if it exists.