I'm using the below code, attempting to filter a related table for inspections to show a message in the pop-up
var gid = $feature.globalid
console(gid)
var signcount = filter(FeatureSetByName($map,'Sign_Information', ['*']),'parentglobalid = gid')
console(signcount)
var x = typeof(signcount)
console(x)
var sign = count(signcount)
console("sign = "+sign)
var p = ""
when(sign > 1, p = "There are "+sign+" sign surveys on this asset",
sign == 1, p = "There is 1 sign survey on this asset",
p = "There are no sign surveys recorded for this asset")
return p
This just fails and errors in the expression builder.
Further interrogation in Pro gives
I have consoled out the type of the signcount to rule out issues there.
What's the inevitably very obvious thing I'm missing?
Thanks
Filter()
TypeOf()
Count()
Console()
When()
*in Proper Case. Does it work?
Could you add the Boolean (includeGeometry?) to FeatureSetByName() function?
I understand it's optional. But still want to tick off that option as the probable cause of the problem.
See below, but looks like I've sorted one problem at least.
The filter wasn't working properly as I hadn't done the SQL query correctly, needed an "@" before "gid" to set it as an arcade variable.
Still not working in the actual pop-up, but it is working in the expression builder.
Your filter clause is failing due to incorrect syntax. "gid" is a string variable, not the actual value for parentglobalid. Use this syntax
var signcount = filter(FeatureSetByName($map,'Sign_Information', ['*']),"parentglobalid = '" + gid + "'");
It's not even as complicated as that.
var signcount = filter(FeatureSetByName($map,'Sign_Information', ['*']),'parentglobalid = @gid') to declare it as an arcade variable
That's a more concise syntax I didn't know about. Is your script working now?