This is stupid but I'm finding the Arcade Intersect function to be fickle - some days it'll work, some days it'll not work.
Intersects will work with $map and $datasource but not Portal. Esri has told me using Portal is an enhancement. That's fine but sometimes it works and sometimes it doesn't. That seems to remove the "science" from computer science.
//this works
var myFeatures = FeatureSetByName($map, myLayer, ['*'], true);
var intersectedZone = First(Intersects($feature, myFeatures));
return intersectedZone["District_N"];
//this works
var myFeatures = FeatureSetByName($datasource, myDataSource, ['*'], true);
var intersectedZone = First(Intersects($feature, myFeatures));
return intersectedZone["District_N"];
//this worked yesterday but not today
var myFeatures = FeatureSetByPortalItem(myPortal, myID, 1, ['*'], true);
var intersectedZone = First(Intersects($feature, myFeatures));
return intersectedZone["District_N"];
Since it worked yesterday, it's been published to a map service and is working fine in a web map. Also, in ArcGIS Pro, I have other Arcade Expressions using this some configuration with Portal and it works wonderfully in ArcGIS Pro (unless I open the expression and try to validate or click OK.
The error is "Invalid expression. Error on line 1. General evaluation error." Sadly line 1 is a comment
//GET THE INTERSECTING LAYER
If I put a "return;" before the Intersect function, it validates. So I know this is the error. Plus, I can also do "return Count(myFeatures);" before the Intersect function and it'll validate and work.
Why did it work yesterday and not today?
Solved! Go to Solution.
Today is Wednesday. On Tuesday, the validate worked (for the most part - sometimes it would throw the error but if I clicked OK enough times, the Arcade Expression builder would close and it would work - [insert facepalm]). I tried a couple of times today and no errors are being thrown.
The only thing that changed was a Windows 11 update so let's blame this problem on Microsoft and call it a day!
UPDATE: I did a little more digging and it seems to be a problem with all Geometry functions in Arcade. I tried Overlaps, Touches, and Within and none of these will validate.
Today the Intersects function validates. 🙃
For those keeping a scorecard, I'll let you know tomorrow if it'll validate. . . .
Today is Wednesday. On Tuesday, the validate worked (for the most part - sometimes it would throw the error but if I clicked OK enough times, the Arcade Expression builder would close and it would work - [insert facepalm]). I tried a couple of times today and no errors are being thrown.
The only thing that changed was a Windows 11 update so let's blame this problem on Microsoft and call it a day!