I have an arcade expression that works perfectly fine in Map Viewer but when I access the map in Field Maps it always returns "No closest weather station was found within the search distance".
Any help on why this is would be greatly appreciated.
The expression is below:
Are you offline when you use Field Maps? This expression would require access to the internet in order to get information from the weatherStations featureset.
Yes, all online. I am aware that when you move offline that this functionality does not work.
Curious. I don't see anything obvious in the expression otherwise. We use "FeatureSetByPortalID" functions in Field Maps without issue, but it may be worth adding the layer to the map and testing @DougBrowning 's suggestion just to see.
Are you testing in Field Maps with the same login as you use in the Map Viewer? Could it be a sharing permission set on the absent layer?
I think it is from using FeatureSetbyProtalID. Change to FeatureSetByName and use the name from the map. See if that does it.
The actual hosted feature layer is not contained in the map therefore I cannot use the FeatureSetByName. I have another expression that pulls property information (not contained in the map) that uses FeatureSetByPortalID and it works fine.
Ok next idea is this line (closestWeatherStationTemp != null) change to isEmpty Not sure just null works?
Checking null works, at least in other contexts. Wouldn't be the first time there was a notable discrepancy between one version of Arcade and another, though.
Not sure what declaring a var with no value does even? It would not even have a type? Maybe set it to '' instead then check that.
I would use Console and see what closestWeatherStationTemp is getting.
Correct, it's just a null, no type. Makes it easier to later just assign values without declaring it over and over inside the loop.