Select to view content in your preferred language

Sign Management Sign ID

259
1
07-17-2025 08:30 AM
LindseyStone
Frequent Contributor

I'm deploying the Sign Management solutions and just appended 6,000 signs from our existing records to the hosted feature via ArcGIS Pro.  There is a Sign ID field that has an Arcade Expression in the ArcGIS Online Form Editor that auto calculates incrementing values on Adding a feature .  How do I apply this same code to my appended records to create that Sign ID for them?

 

var layerIndex = '4'
var idField = 'assetid'
var idPrefix = 'POLE-' 
var digits = 6

/*DO NOT CHANGE ANYTHING BELOW THIS LINE
-------------------------------------------------------------------------*/

function GenerateWildcards(digits, wildcard) {
  var wildcards = ''
  for (var i=0; i < digits; i++) {
    wildcards += wildcard
  }
  return wildcards
} 

function GetNextId(layerIndex, idField, idPrefix, padding, sqlFilter) {
  // get the feature with the greatest assetid that matches the id pattern specified in the SQL statement.
  var assetid_features = Filter(FeatureSetById($datastore, layerIndex, [idField], false), sqlFilter)
  var max_assetid_feature = First(OrderBy(assetid_features, `${idField} DESC`))  

  // If no features match the pattern the featureset will be null, return the first assetid
  if(max_assetid_feature == null) {   
    return `${idPrefix}${Right(padding, Count(padding)-1)}1`
  }

  // when features do match the pattern calculate and return the next assetid  
  var max_assetid = max_assetid_feature[idField]
  
  var next_assetid_number = Number(Replace(max_assetid, idPrefix, "")) + 1
  return `${idPrefix}${Text(next_assetid_number, padding)}`
}

// Define the edit context so the value is only calculated when the feature is created
if ($editContext.editType == "INSERT") {
  // return matching prefix pattern and get next value
  var wildcards = GenerateWildcards(digits, '_')
  var padding =  GenerateWildcards(digits, '0')
  if (idPrefix != '') {
    var sqlFilter = `${idField} LIKE '${idPrefix}${wildcards}' AND ${idField} NOT LIKE '%[^0-9]'`    
    GetNextId(layerIndex, idField, idPrefix, padding, sqlFilter)
  }

// return number id's only and get next value
  else {
    var sqlFilter = `${idField} NOT LIKE '%[^0-9.]%'`    
    GetNextId(idPrefix, padding, sqlFilter)
  }

}
else {
  return $feature[idField]
}

   

0 Kudos
1 Reply
DanielWickens
Esri Contributor
 

@LindseyStone 

You can use the tasks in the Sign Data Management Pro Project that's delivered with the solution to connect to the hosted layers. You can then use the Assign Sign ID task step to fill out Sign ID incrementally. It will overwrite whatever is currently in that field.
0 Kudos