Greetings. I'm trying to create an attribute rule to automatically name objects when they are created. Our naming convention requires using an asset id grid where the grid name is incorporated into the asset name. I written an Arcade Expression that works when calculating a field. When I then try to use that same expression as code in an attribute rule, I get a 002717 error indicating an unexpected null value. I tried submitting or Arcade expressions that are much simpler and also get the same error. I don't understand why the code runs without issue in the calculate field tool, but kicks back an error when being used as an attribute rule. I understand I am not adding the code properly in the forum, I cannot seem to find the right way to add it. I'm adding the code in the text below.
var agrid = (FeatureSetByName($datastore, 'DBO.CAIDGD', ['Utility_ID']));
var gridid = First(Intersects(agrid, $feature));
return gridid.Utility_ID;
The above three lines of code work in the calculate field, but do not pass as an attribute rule. The above code is simplified in a much larger script as a single line of code below.
var currentValue = First(Intersects(FeatureSetByName($datastore, 'DBO.CAIDGD',['Utility_ID']),$feature)).Utility_ID;
In the larger script, the above code is the line identified with the 002717 error when I try to use the script in an attribute rule calculation rule.
Thanks all.