Arcade: create an array of field values

10791
15
06-04-2020 12:59 PM
JoeBorgione
MVP Emeritus

As the subject line suggests, I would like to create an array of all the values of a given field in a table.  The end goal is to create an attribute rule that can check a string against the array and make sure the string is in fact part of the array.

In arcpy, I would use the da.SearchCursor and append the values of the field to a list.  How does one accomplish the same basic operation in Arcade?

I never know what Geonet space to post Arcade questions to, so I'm tossing this into the ArcGIS Pro space...

That should just about do it....
0 Kudos
15 Replies
JessePapez__-_RR
New Contributor II

To build on this, without using IndexOf on a fs, can we return the position of the returned value in the sorted not-array?

0 Kudos
JoeBorgione
MVP Emeritus

Thank you for your detailed response Xander Bakker‌.  With respect to your question regarding domains, they have a significant limitation in an enterprise geodatabase environment.  Only the domain owner can update them.  I am currently working on an implemention of ESRI's Address Data Management Solution.  One of the tasks in the solution has you update the master street name file and then use that file to create the domain.  That approach works, sort of.  In addition to the domain edit limitations, I find trying to pick a valid street name from a mile long list impractical.

My thought process is if all users can edit the master street name file I'd like to run a verification against a new centerline street geometry insert such that the name entered on the new street is already in the master street name file. If it is, great, if not return some sort of warning to the effect of 'Hey there, your new street name isn't in the master streets file' which could mean the new street name was misspelled or simply has not been added.

At any rate, your suggestions are exactly what I was hoping to get, and I'll get after it as soon as I get back to the office in the morning.

Thanks again!

That should just about do it....
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Joe Borgione , 

Thanks for the additional explanation on your use case. You are right, scrolling through a long list of street names is not very user-friendly. If you would have the area subdivided in areas, you could use contingent values to reduce the list of streets based on the area selected by the user. 

JoeBorgione
MVP Emeritus

Here is another solution provided by Chris Fox‌ that he specifically prototyped for the Address Data Management Solution as a constraint type attribute rule.  I find this approach very interesting; there is a contrast in what I follow as the 'traditional' python mindset and what Chris offers here in Arcade.

// This constraint rule will ensure the full name exist in the master road name table

// Get the full name of the road. If it is null return the fullname

var fullname = $feature.fullname;
if (IsEmpty(fullname)) return fullname;

// Search the master road name table for a row matching the fullname.
// If there is no matching record raise an error preventing the edit

var masterStreetNames = Filter(FeatureSetByName($datastore, "MasterRoadName"), "fullname = '" + fullname + "'");
if (Count(masterStreetNames) == 0) {
                return {
                        "errorMessage": "Full Road Name is invalid, must be defined in the Master Road Name table."
                }
}
return true;
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
That should just about do it....
XanderBakker
Esri Esteemed Contributor

Hi jborgion ,

He is using the same approach as I mentioned at the end of my initial answer (check for the count after using a filter), although his rule is properly formatted as a validation rule.  

JoeBorgione
MVP Emeritus

Xander Bakker‌; yes, I would/could be able to subdivide the street names by our townwhips.  I'll take a look at contingent values as suggested. Updating domains in the egdb are still an issue, but I haven't yet decided how I'm going to implement the solution.  I could edit a check out replica in a file geodatabase which could then use the domain there, and not worry about a domain in the egdb...

That should just about do it....
0 Kudos