Check for Duplicate AssetID Values with Arcade

3091
11
05-28-2020 11:35 AM
Billy
by
Occasional Contributor II

Hi,

I have an Arcade rule that generates an assetid when a point is inserted. This code is generated by measuring and rounding the distance, in feet, of the inserted point feature from a fix reference point. The process could generate repeated assetids for point features that are located at the same distance from the reference point.

Therefore, I'm trying to compare the new assetid with the existing ones using 2 for loops, with the code shown below.

The code tries to compare the new assetid against all the existing (inner loop), if there is a duplicate then change the new assetid, compare again, and if there is no duplicate then exit the outer loop.

The rule is not work. It never enters the if statement inside the inner loop, see code below. I purposely created duplicate assetids, as you can see in the pic below. Tried adding a point and saving the edit, then adding another one and saving again, in case the Arcade rule was not seeing the repeated assetid until the edits have been saved; but that didn't work.

Is there something wrong on the code or there is a better and more efficient way to do this?

0 Kudos
11 Replies
JohnAlsup
Esri Contributor

Objectid is only unique to that database.  If you use any type of disconnected capabilities, your objectid's are not maintained and will be different between databases.  I would not use ObjectID as a unique ID.  

John Alsup
jalsup@esri.com
0 Kudos
RobertBorchert
Frequent Contributor III

You put the object id into a text field. I was under the assumption you were creating AssetID which is where you would put the objectID.  Then add something to distinguish that it belongs to that Feature Class.  

And possibly format the number so it is  X number of characters long. 

example.

New handhole.  ObjectID 4824  formatted to HH004824    You would not use the objectID as the unique identifier for that Handhold because as you said when it goes to a different system the objectID's are new, but the unique AssetID would go where ever. 

Using objectID as the BASE of the AssetID would prevent you from creating duplicate AssetID's automatically. 

0 Kudos