Arcade Attribute Calc Rule Function "Contains" fails on Server

1177
3
Jump to solution
09-28-2020 07:44 AM
NicoLuus
Esri Contributor

Good day all.

I think I might have encountered a bug but before reporting it as such I would like to ask if somebody else can replicate this issue.

Context: I have a polygon FC which should count how many points it encloses and return the number upon creation.

Software Version: ArcGIS Pro (2.5.1), ArcGIS Server (10.71)

Arcade Script of Polygon FC: 

var GeopointFS = FeatureSetByName($datastore, "STAGING.LDR.Geo_Frame");
var ContaindPts = Contains($feature, GeopointFS)
if (ContaindPts < 1) {return null}
if (IsEmpty(ContaindPts)) { return null}
var CntGP = Count(ContaindPts);
return CntGP

This script works perfectly fine when running on FC level, however when publishing and running it using the service I receive the following error on line 2: 

Arcade Error: Geometry type or nulle expected.

On the left, I attempt to add a polygon in ArcGIS Pro using the Feature Service.

On the left I attempt to add a polygon using the Feature Service, on the right using the Feature Class.  The latter works as expected.

From the ArcGIS Arcade version matrix found here, it is indicated that the "Contains" function, which is supported from Arcade verson 1.7 onwards should work on ArcGIS Enterprise server 10.7.1.

Anybody else encountered this yet?

Thanks for your considerations

Nico

arcade geometry, contains(), attribute-rules, attribute calculation error, arcade 1.7‌

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Nico Luus ,

It is a good thing that you checked the version matrix and you are right, the Contains function was introduced at Arcade version 1.7 which corresponds to Enterprise 10.7.1.

Perhaps I would first start with validating if the first line is correct for accessing the points. Are they in the same $datastore as the current feature, is the name correct, etc? Did you use the interface to construct the Arcade expression or did you manually type in the name of the featurelayer?

You could also try to use the Intersects function instead of the Contains function and see if the result is different:

var GeopointFS = FeatureSetByName($datastore, "STAGING.LDR.Geo_Frame");
var fsint = Intersects(GeopointFS, $feature);
var cnt = Count(fsint);
return cnt;

Notice that I am not returning null. If it does not find any points in the polygon it would be logical to state that there are 0 points, but maybe your requirements are different.

Some other considerations:

  • Do you have rules in place in case the points change?
  • Do you also trigger the update of the polygons to recalculate the number of points?

View solution in original post

3 Replies
XanderBakker
Esri Esteemed Contributor

Hi Nico Luus ,

It is a good thing that you checked the version matrix and you are right, the Contains function was introduced at Arcade version 1.7 which corresponds to Enterprise 10.7.1.

Perhaps I would first start with validating if the first line is correct for accessing the points. Are they in the same $datastore as the current feature, is the name correct, etc? Did you use the interface to construct the Arcade expression or did you manually type in the name of the featurelayer?

You could also try to use the Intersects function instead of the Contains function and see if the result is different:

var GeopointFS = FeatureSetByName($datastore, "STAGING.LDR.Geo_Frame");
var fsint = Intersects(GeopointFS, $feature);
var cnt = Count(fsint);
return cnt;

Notice that I am not returning null. If it does not find any points in the polygon it would be logical to state that there are 0 points, but maybe your requirements are different.

Some other considerations:

  • Do you have rules in place in case the points change?
  • Do you also trigger the update of the polygons to recalculate the number of points?
NicoLuus
Esri Contributor

Hi Xander Bakker

Thanks for the quick reply.

Yes I can confirm that the "Geo_Frame" point FC is indeed in the same $datastore as the "Sections" polygon FC (The one the rule is built on) and I used the interface to add these.

The code itself should not be a problem since it functions as expected when I capture polygons using the FC.  The error message is encountered as soon as I publish it as a Feature Service (FS) and then try and capture a "Sections" polygon using this FS.

I have used "Intersects" instead of the "Contains" function, as you proposed, and it works!:

Comparison of capturing data using FC & FS and the Arcade Attribute Calc rule using the Intersects function.

Using "Intersects" rather than "Contains" will satisfy my requirement but I am quite confident that there is a bug with the "Contains" function after my test results.

What is the next step in reporting it?

Could anybody else replicate the error?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Nico Luus ,

As you mentioned, there might be an issue with the Contains function (at least it seams that way). I would recommend you to contact Esri Support and work with them to report the issue.