I'm just starting to use Arcade - like it a lot so far but there is one scenario that I can't figure out. I want to retrieve the set of related records associated with a feature for my ArcGIS Online web map popup. I can do this with this statement
var fs = FeatureSetByRelationshipName($feature, "Program", ["ProgramName"], false);
It works great except when the feature has no related records. I still get a FeatureSet returned, and I would expect it to contain zero features. But any method I use to access the FeatureSet returns "Execution Error:Cannot read property 'toString' of null". I've tried all of the following:
What is the trick to allow me to detect in my code that the feature set is empty?
Solved! Go to Solution.
Hello Everybody,
I have the same problem than DonMorrison1 but I can't solved it. I got the same error msg.
I tried the little code of Dan but it doesn't work .
Any idea?
Thanks a lot
Your "build out popup" code is wrong.
If you only want to return the first entry of relateData:
var firstRelateData = First(relateData)
if(firstRelateData == null) { // no related data
return "null"
}
return firstRelateData.num_arret
If you want to return all related features:
if(Count(relateData) == 0) { // no related data
return "null"
}
var all_num_arrets = []
for(var f in relateData) {
if(f.num_arret != null) {
Push(all_num_arrets, f.num_arret)
}
}
return Concatenate(all_num_arrets, ", ")
Thank you Johannes but I Got the same problem. I can't count the relateData with the filter, the problem is in.
I don't understand this error msg because I have data in each row of my table.
Hmmm. Try adding this at the start of your script:
if(IsEmpty($feature.IDARRET)) {
return "null"
}
yes it works. Thank you!!
Juste one more question about it: do U know how can i put a little symbol just before my attributes. When i do like this
for(var f in relateData) {
if(f.num_arret != null) {
Push(all_num_arrets,
` "https://xxxxxxxx/rest/content/items/9e3929af55db440ea45c5f72e37cd3c5/data" ${f.hor_theo_1mn} `)
Push(all_num_arrets,
` "https://xxxxxxxx/rest/content/items/9e3929af55db440ea45c5f72e37cd3c5/data"${f.hor_theo_2mns} `)
}
}
, it just gives me the URL and not the image.
Thank you
Arcade doesn't evaluate HTML. Maybe what you want to do is possible, but it will be a little complicated.
I suggest posting a new question for this, as this goes far beyond the scope of the original question, and you'll get more views and potential answers.