Select to view content in your preferred language

How return all values/attributes of table using arcade?

880
5
Jump to solution
08-22-2022 07:33 AM
anonymous55
Frequent Contributor

Hello

I have this code which return specific fields but right now I need to return all values. I can write all attribute in code but the table I refer has lots of fields. is it any way I can get all fields on table to use it in pop up in web map

 

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

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor
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))

if(cou == null) { return "no survey found" }

var attributes = Dictionary(Text(cou))["attributes"]
var popup_lines = []
for(var a in attributes) {
    var line = `${a}: ${attributes[a]}`
    Push(popup_lines, line)
}
return Concatenate(popup_lines, TextFormatting.NewLine)

Have a great day!
Johannes

View solution in original post

0 Kudos
5 Replies
JohannesLindner
MVP Frequent Contributor

Something like this?

var attributes = Dictionary(Text($feature))["attributes"]
var popup_lines = []
for(var a in attributes) {
    var line = `${a}: ${attributes[a]}`
    Push(popup_lines, line)
}
return Concatenate(popup_lines, TextFormatting.NewLine)

 

JohannesLindner_0-1661179635177.png

 


Have a great day!
Johannes
anonymous55
Frequent Contributor

Thanks Sorry I am kinda new to this Arcade code 
How can I combine your code with mine.

0 Kudos
JohannesLindner
MVP Frequent Contributor
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))

if(cou == null) { return "no survey found" }

var attributes = Dictionary(Text(cou))["attributes"]
var popup_lines = []
for(var a in attributes) {
    var line = `${a}: ${attributes[a]}`
    Push(popup_lines, line)
}
return Concatenate(popup_lines, TextFormatting.NewLine)

Have a great day!
Johannes
0 Kudos
anonymous55
Frequent Contributor

Thanks @JohannesLindner This is working fine but if I don't want to list  attributes and bring everything without writing because table has lots of fields 

0 Kudos
JohannesLindner
MVP Frequent Contributor

I'm not quite sure what your question is. I'm assuming you want to limit the fields that get printed. You can do that like so:

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))

if(cou == null) { return "no survey found" }

var attributes = Dictionary(Text(cou))["attributes"]
var print_fields = ["age", "gender", "race"]  // define the fields you want to print in the popup
var popup_lines = []
for(var f in print_fields) {
    var a = print_fields[f]
    var line = `${a}: ${attributes[a]}`
    Push(popup_lines, line)
}
return Concatenate(popup_lines, TextFormatting.NewLine)

Have a great day!
Johannes
0 Kudos