Solved! Go to Solution.
I was able to get this working. Not sure why I was having issues before.
To post code:
Try doing a null check:
var incident = $feature.incident_number
if(incident == null) { return "No Incident number!" }
var u = ...
I was able to get this working. Not sure why I was having issues before.
You had issues before because you didn't have the null check.
When IncidentNumber is null, codeStatement will be "incident_number = ". That is an invalid sql statement, so the Filter() function will fail.
When the Arcade expression is validated, it uses default values (I think, not too sure about that. @jcarlson ?), so the expression didn't get validated because it raised an error, until you set incident to a non-null value.
With the null check I suggested, you return a default response if the IncidentNumber is null. When you return from a script, the rest of the script isn't executed anymore, so Filter() doesn't get a chance to raise an error, so the expression validates.
I think it depends on where you test the expression. In Pro, I often get the green check mark for a valid expression, but there's actually invalid data in the table that throws an error somewhere further down. But I can test the same expression in a web context and get the error identified right away, so I would guess there is something going on with default values. Hard to fully observe it, though.