Hello everyone,
is it possible to create a rule using Arcade that assigns an individual number starting from 1 to an object?
When placing an object, it should receive the number 1. When placing a second object, the second object should receive the number 2. And so on...
Now, if I have 10 objects numbered from 1 to 10, and let's say I delete object number 5, all the objects following 5 should be renumbered from 6 to 9.
Is this possible?
Solved! Go to Solution.
It might be possible but I think it could be horribly inefficient. Imagine you've got 10,000 records and you delete record number 5, since attribute rules are executed against one record at a time you'd need to wait for 9,995 updates to take place.
What do you need a sequence like this for? Assuming you aren't working with versioned data, you could derive it from the Object ID at the time it's required. If you are working with versioned data, you could use editor tracking and the create date to perform this type of operation at the time it's required.
It might be possible but I think it could be horribly inefficient. Imagine you've got 10,000 records and you delete record number 5, since attribute rules are executed against one record at a time you'd need to wait for 9,995 updates to take place.
What do you need a sequence like this for? Assuming you aren't working with versioned data, you could derive it from the Object ID at the time it's required. If you are working with versioned data, you could use editor tracking and the create date to perform this type of operation at the time it's required.
I am working with a predefined range of numbers that need to be assigned to cabinets. The maximum number of assigned numbers will never exceed 20. This should still be within the limits, right?
Is it possible to create a rule for this in Arcade? And how would it look like?
I think it would be reasonable with a maximum 20 records. I don't write these types of Arcade statements very often so I'd defer to others (I did put a rough idea below however), but are you working in an Enterprise environment with versioning? If so I don't think it would be possible without the risk of ID collisions upon reconciliation.
If you aren't working with versioning, I think something like these two rules would work:
Alternatively, as part of your editing workflow, create a simple Python script (maybe deployed as a GP tool) that reads the features in an update cursor, ordering by OID or creation date, and sets the IDs in a sequence. You could also do this with the Field Calculator and the "Code Block" parameter. Again, if versioning is involved, it gets more complicated (but still possible this way).
Also, just to be 100% sure, what is your data source? A File GDB? Or - since this question is under the ArcGIS Online community - are you using an ArcGIS Online hosted feature layer? If it's an AGOL feature layer I'm fairly certain they don't support attribute rules yet.
Take a look at this thread: