Select to view content in your preferred language

Create Street Name Validation

126
14
Thursday
SarahWright
Emerging Contributor

I am trying to create an attribute rule that validates if a street name is in a master street table when being created. Here is the code I have so far, I am not sure where my syntax is wrong. 

The expression needs to be case in-sensitive, the source data in the master table is mixed casing.

 Thanks in advance!

// 1. Access the reference table by name
// This must match the name of the layer in your database/service
var masterStreetName = Upper(FeatureSetByName($datastore, 'vwAddresserData_v2', ["FULLADDRESS"], false));

// 2. Get the address being entered/edited
var addresserStreetName = Upper($feature.FullStreetName);

// 3. Handle empty values (optional: allow or block nulls)
if (IsEmpty(addresserStreetName)) { return true; }

// 4. Filter the other table for matching addresses
// Use Upper() to ensure the comparison isn't case-sensitive
var filterSQL = "FULLADDRESS = '" + addresserStreetName + "'";
var matches = Filter(masterStreetName, '@filterSQL');

// 5. Logic: Return true if a match is found, false (with message) if not
if (Count(matches) > 0) {
return true;
} else {
return {
"errorMessage": "The address " + addresserStreetName + " does not exist in the master Street table."
};
}

0 Kudos
14 Replies
MikeMillerGIS
Esri Frequent Contributor

Try this.  Also, when posting code, please use a code samples(Javascript works good for arcade).  Makes it much easier to read

if (IsEmpty($feature.FullStreetName)) 
{
	return true; 
}

var addresserStreetName = Upper($feature.FullStreetName);
var masterStreetName = FeatureSetByName($datastore, 'vwAddresserData_v2', ["FULLADDRESS"], false);
var matches = Filter(masterStreetName,  "UPPER(FULLADDRESS) = @addresserStreetName");

if (Count(matches) > 0) 
{
	return true;
} 
return {"errorMessage": "The address " + addresserStreetName + " does not exist in the master Street table."};

 

0 Kudos
SarahWright
Emerging Contributor

Thanks for the suggestion, I am now getting the below error.

Edit operation failed.
Failed to evaluate Arcade expression. [
Rule name: Invalid Street Name,
Triggering event: Update,
Class name: L0addresserData,
GlobalID: {1986C779-DA03-40F1-9FF9-60E436BF5926},
Error number: 1001,
Error message: Street Name is not in the master Street Name table.,
Arcade error: Table not found {F373DE5C-427D-466E-92A5-5988CFD4D5CA},
Script line: 7]

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

I do not know, I do not have access to the data so very hard to tell.  Can you verify the name of the master street name table?  Does you street have a street name of "Street Name"

0 Kudos
SarahWright
Emerging Contributor

This part of the error is returned from the error statement I created for the error number. 

Error number: 1001,
Error message: Street Name is not in the master Street Name table

It should not be looking for street name. That is not in the code.

It is very hard to tell. Do you know of a better way to troubleshoot the arcade expression? I have tried so many code variations at this point. 

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Do you happen to have any other attribute rules?  The error message does not match the code above.

0 Kudos
SarahWright
Emerging Contributor

Here is the configuration to my rule. There are no other rules with this error message.

SarahWright_0-1778176370985.png

 

0 Kudos
SarahWright
Emerging Contributor

The table name is slightly different in my picture. Another variation I tried to see if it would connect to another table.

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Ok, That helps.  The error is that the FeatureSetByName cannot find table.  Can you move it all to a file geodatabase for testing to ensure the rule works?  That would help eliminate variables with enterprise databases and permissions.

 

0 Kudos
SarahWright
Emerging Contributor

Hi, thanks for your help on this. Moving the data into GDB and editing returned the expected results. My goal is to be able to use this in a editing web application. I am not sure what I was doing wrong. Any insight on getting this into our web application is greatly appreciated.

I am working on this in our dev ArcGIS Enterprise environment 11.5. Using enterprise gdb version 11.5 and ArcGIS pro 3.5.

Thanks

0 Kudos