Arcade expression doesn't show in pop-up

791
3
Jump to solution
03-09-2022 01:46 PM
anonymous55
Occasional Contributor II

Hello, 

I have this code and I getting result in test but I can't set it up in pop-up of new map viewer?

var intersectLayer =Top(OrderBy(FeatureSetByName($map,"xyz"),"Inspection_Date DES"), 3);

return intersectLayer

and this is I am seeing on pop-up

ARM_0-1646862342247.png

 

Tags (2)
0 Kudos
2 Solutions

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

intersectLayer is a FeatureSet. It will be shown in the expression builder's test, but popups can't show it.

You have to build a string:

var inspection_dates = []
for(var f in intersectLayer) {
    Push(inspection_dates, f.Inspection_Date)
}
return Concatenate(inspection_dates, TextFormatting.NewLine)

Have a great day!
Johannes

View solution in original post

JohannesLindner
MVP Frequent Contributor
  • You're using Text() on a feature, which returns a json string containing info about the geometry and attributes of the feature. What you want to do is extracting the fields of the feature, not the whole feature. 
  • You're not adding to your popupText sring. Instead you reassign a new value to it each time, which is why you only see one line as a result.
  • There's no need to call Text() here. Your fields are all strings, the number format won't do anything. What you could do is using DefaultValue() to insert some meaningful text if there's a null value in a field.
var popupLines = [
    "Age: " + DefaultValue(cou.age, "not reported"),
    "Gender: " + DefaultValue(cou.gender, "not reported"),
    "Race: " + DefaultValue(cou.race, "not reported"),
]
return Concatenate (popupLines, TextFormatting.NewLine)
// or comma sepated:
// return Concatenate(popupLines, ", ")

Have a great day!
Johannes

View solution in original post

0 Kudos
3 Replies
JohannesLindner
MVP Frequent Contributor

intersectLayer is a FeatureSet. It will be shown in the expression builder's test, but popups can't show it.

You have to build a string:

var inspection_dates = []
for(var f in intersectLayer) {
    Push(inspection_dates, f.Inspection_Date)
}
return Concatenate(inspection_dates, TextFormatting.NewLine)

Have a great day!
Johannes
anonymous55
Occasional Contributor II

Hello

I have this code which bring different fields from another layer to pop up but I can't get the result on popup

var fips = $feature["parent_id"]

var dd = FeatureSetByName($map,
"Survey v2", ['age','gender','race'],False)

var fillterSur = "survey_id = @fips"

var cou = First(Filter(dd, fillterSur))

var popupTEXT = "Age: "
+Text(cou,'#,###')
var popupTEXT = "gender: "
+Text(cou,'#,###')
var popupTEXT = "race: "
+Text(cou,'#,###')

return popupTEXT

 

The result I am getting is like this :

anonymous_0-1659712636612.png

0 Kudos
JohannesLindner
MVP Frequent Contributor
  • You're using Text() on a feature, which returns a json string containing info about the geometry and attributes of the feature. What you want to do is extracting the fields of the feature, not the whole feature. 
  • You're not adding to your popupText sring. Instead you reassign a new value to it each time, which is why you only see one line as a result.
  • There's no need to call Text() here. Your fields are all strings, the number format won't do anything. What you could do is using DefaultValue() to insert some meaningful text if there's a null value in a field.
var popupLines = [
    "Age: " + DefaultValue(cou.age, "not reported"),
    "Gender: " + DefaultValue(cou.gender, "not reported"),
    "Race: " + DefaultValue(cou.race, "not reported"),
]
return Concatenate (popupLines, TextFormatting.NewLine)
// or comma sepated:
// return Concatenate(popupLines, ", ")

Have a great day!
Johannes
0 Kudos