Select to view content in your preferred language

Attribute Rules: NextSequenceValue in a file database environment.

6649
25
Jump to solution
01-30-2020 06:44 AM
by Anonymous User
Not applicable

Attempting to create sequential IDs for managing above ground assets.

I successfully create the database sequence and have been working with two scripts. 

1.) Returns zeros in the FID field

--------------------------------------------------------------------------------------

var FID = $feature.FID;
($feature.FID == 1)
return "SP-" + NextSequenceValue("Traffic_SignalPole_ID")

--------------------------------------------------------------------------------------

2.) The FID values remain Null

----------------------------------------------------------------------------------------

var FID = $feature.FID;
(FID == 1)
return "SP-" + NextSequenceValue("Traffic_SignalPole_ID")

----------------------------------------------------------------------------------------

If is put an "if" before the second line regardless, the field value will be null.

Also when I check the table in arc catalog is shows that the sequence is adding to the database table, but is still not being appended to the feature its self.

0 Kudos
25 Replies
ChristopherBowering
Occasional Contributor III

That makes sense.  The live dataset I'll be using this in will be a versioned Enterprise dataset.  We will rarely - if ever - have more than 1 person doing collection at one time and edits will update our master as they occur (unless we need to go disconnected).  I wonder if a home concocted code would work to 'fill in the gaps' since we likely wouldn't have the same degree of barriers as a larger organization.

0 Kudos
RobertKrisher
Esri Regular Contributor

Chris - Yes, but in this sort of case you would likely abandon the sequence approach for numbering in favor of a batch calculation rule and a batch validation rule.  The batch calculation rule would find the next available number for each feature and the batch validation rule would ensure that all the assigned numbers in the system are unique.  Because these are batch calculation rules they must be run manually, and I would recommend running these rules (along with any other attribute rules) as part of you QA review process after reconciling with default and ahead of posting.  

0 Kudos
ChristopherBowering
Occasional Contributor III

Robert - that is a good alternative.  Would I use the exact same script for the batch calculation rule?  As far as I know, I will only be doing a reconcile and post process if 1.) multiple field workers are using the app/data or 2.) if disconnected editing is performed.  Thanks!

0 Kudos
RobertKrisher
Esri Regular Contributor

Chris - The batch calculation rule and batch validation rule would both be completely different.  For validation you would make sure that you hadn't duplicated any numbers, and for batch calculation you would scan every row in the database to identify the first available number.

0 Kudos
ChristopherBowering
Occasional Contributor III

Robert - would you be able to provide the code(s) I could test for the batch calculation and validation?  I am very green when it comes to Arcade and scripting in general.  If not, no worries - you've already helped me tremendously!

0 Kudos
RobertKrisher
Esri Regular Contributor

Chris - I don't have any code for this, but the code you're going to end up writing is going to use the Distinct method ( Data Functions | ArcGIS for Developers  ).  To find the next id you'll get all the distinct IDs (function), sort them (function), then loop through them until you find an opening (loop).  To check for uniqueness, filter the current table to look at everything but the current row, get the distinct values, then check to see if your current value is in that list (each of those steps is just a single function).

0 Kudos