Select to view content in your preferred language

Does your Attribute Rule fail on 3.1 but works on earlier releases? Here is why (The field not found error)

983
2
05-04-2023 03:25 PM
HusseinNasser2
Esri Contributor
4 2 983

Are you getting a field not found error,  in 3.1 for an Attribute Rule that worked in previous ArcGIS Pro? The reason is because we fixed a bug in 3.1 with FeatureSetByName that were incorrectly requesting too many fields than requested.


FeatureSetByName is a function that allows you to query a table and specify what fields to pull back and whether to return the geometry. The result then can be used in the Arcade script. Here is an example where we have a table `mytable` and we are pulling field1 and requesting not to return geometry.

 

var fs = FeatureSetByName($datastore, "mytable", ["field1"], false);
var firstRow = first(fs);
return firstRow.field1;

 

 

Due to a bug in Pro 3.0 and earlier, the software in certain conditions will ignore the requested fields and will return all fields including the geometries during Arcade validations and execution. This means that scripts that should have failed were working here is an example where you only returned field1 but the script is trying to access field2 but the featureset doesn't have it because it only asked for field1

 

var fs = FeatureSetByName($datastore, "mytable", ["field1"], false);
var firstRow = first(fs);
return firstRow.field2; //this should fail because field2 is not in the result set. 

 

 

In prior releases this bug masked these scripts errors and continue to work even when the script isn't correct. In Pro 3.1 Pro and Enterprise 11.1 always respect the requested fields and geometry.

This is unfortunate because we know a lot of our users have scripts that might now fail in the Pro 3.1/11.1 but the good news is scripts will sure run faster consistently as the software will always make sure to request only the fields set by the user in all execution paths and across all database platforms.

 

How to fix?

Pro 3.1 and Enterprise 11.1 will show the line number in which the error is encountered, you can trace back which featureset it came from and make sure that the fields are included.  In our example above we got the error on line 3. So we add field2 to the request list.

 

 

var fs = FeatureSetByName($datastore, "mytable", ['field1', 'field2'], false);
var firstRow = first(fs);
return firstRow.field2; //this should fail because field2 is not in the result set. 

 

 

 

 

 

 

  

 

2 Comments
About the Author
Software Engineer, Author of several GIS books and Software Engineering Content Creator on YouTube and Anchor.fm podcast