Select to view content in your preferred language

Auto Increment on a selected set

296
9
Jump to solution
07-18-2025 01:06 PM
LisaCasey
Regular Contributor

Hi All,

Our highway department likes to number their signs in order with an increment of one east to west/North to south.

The issue is that when a new sign is installed, it upsets the numbering. Users don't like to rely on me to re-number.

To re-number, I add the new sign, then re-number the remaining signs using a selected set and then field calculator in arc pro of field = field +1.

Does anyone know of a way I could create a way for the users to easily click a button to select the features that need to be re-numbered, and then calculate the field = field + 1 on the selected set? 

Right now users are using the edit widget in EXB.

Thank you!

Lisa

0 Kudos
1 Solution

Accepted Solutions
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Sure thing. Here is a really basic rule that should give you some idea as to how that workflow would look like.

/*
There are multiple ways to write the same kind of arcade code
but here are a few examples that ultimately return the same result
*/

/*
defintiions:
	'<InsertCriteriaFieldname>': is the field name where you only that specific field determines the change
	'SomeValue': is the value that the criteria field is set to trigger the change
    '<InsertIncrementingFieldname>': the id field that has the incrementing id added
*/

// This gets the max value of the entire set of records in a featureclass/table
var M = Max( $featureset, '<InsertIncrementingFieldname>' )

// Option 1
var V = $feature.'<InsertIncrementingFieldname>'
IIF( $feature.'<InsertCriteriaFieldname>' == 'SomeValue', M+1, V )
	
// Option 2
IIF( $feature.'<InsertCriteriaFieldname>' == 'SomeValue', M+1, $feature.'<InsertIncrementingFieldname>' )
	
// Option 3
if( $feature.'<InsertCriteriaFieldname>' == 'SomeValue' ){ return M+1 }
else{ return }

Something else that I just remembered is that Survey123 surveys can also be added, which if you did not know, also uses the arcade functionality. This is similar to attribute rules with the only difference being that it can work on both hosted services and feature services. If you are primarily using a hosted service then this might be the best workflow, otherwise a feature service with attribute rules is better suited.

* Note: I have not played around too much with Survey123, but I have a lot of experience with arcade so this should hopefully get you in the right direction.

Another helpful resource is the arcade playground and the arcade resources.

View solution in original post

0 Kudos
9 Replies
JeffreyThompson2
MVP Frequent Contributor

https://mediaspace.esri.com/media/t/1_j3pdmx60

This feels like something that would need to be accomplished through a Webhook.

GIS Developer
City of Arlington, Texas
0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

HI @LisaCasey,

So there isn't a button that can do this but there is a workflow that can be created using the arcgis arcade and either a calculation in Field Maps or Survey123, or creating an attribute rule in an sde feature class.

We currently are using a similar capability to allow our field personnel to make changes to selected feature. Depending on which feature is selected and which attribute criteria is met; will a new id be generated for that feature. I can provide you a small arcade example if need be.

Ideally an attribute rule would be the best fit given the scenario that your trying to accomplish.

0 Kudos
LisaCasey
Regular Contributor

Hello @RPGIS ,

If you would be willing to share your Arcade, I would be eternally grateful! I have not used attribute rules. Now is a good time to learn how 🙂

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Sure thing. Here is a really basic rule that should give you some idea as to how that workflow would look like.

/*
There are multiple ways to write the same kind of arcade code
but here are a few examples that ultimately return the same result
*/

/*
defintiions:
	'<InsertCriteriaFieldname>': is the field name where you only that specific field determines the change
	'SomeValue': is the value that the criteria field is set to trigger the change
    '<InsertIncrementingFieldname>': the id field that has the incrementing id added
*/

// This gets the max value of the entire set of records in a featureclass/table
var M = Max( $featureset, '<InsertIncrementingFieldname>' )

// Option 1
var V = $feature.'<InsertIncrementingFieldname>'
IIF( $feature.'<InsertCriteriaFieldname>' == 'SomeValue', M+1, V )
	
// Option 2
IIF( $feature.'<InsertCriteriaFieldname>' == 'SomeValue', M+1, $feature.'<InsertIncrementingFieldname>' )
	
// Option 3
if( $feature.'<InsertCriteriaFieldname>' == 'SomeValue' ){ return M+1 }
else{ return }

Something else that I just remembered is that Survey123 surveys can also be added, which if you did not know, also uses the arcade functionality. This is similar to attribute rules with the only difference being that it can work on both hosted services and feature services. If you are primarily using a hosted service then this might be the best workflow, otherwise a feature service with attribute rules is better suited.

* Note: I have not played around too much with Survey123, but I have a lot of experience with arcade so this should hopefully get you in the right direction.

Another helpful resource is the arcade playground and the arcade resources.

0 Kudos
LisaCasey
Regular Contributor

Thank you so much!

I will keep you posted on my ability to implement. Options one and two look like they would both work.

I have to figure out if/how i can implement this in an EXB edit widget.

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

The options I indicated all accomplish the same thing. I gave several examples because some people don't realize how programming works in general and don't really understand that there are multiple avenues that can be implemented to arrive at the same result. It is all a matter of preference and readability at that point.

Edits made in EXB are tied to whatever attribute rule/calculation are set. If you are using the survey function in EXB then that is tied to the survey, otherwise if you are using an attribute rule on a feature class/table then it will automatically execute whenever the edit conditions are met.

If calculations on an edit do not exist in EXB then you do have the option to create an idea for the community but please note that because these edit capabilities exist elsewhere it may not be possible.

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

The options I indicated all accomplish the same thing. I gave several examples because some people don't realize how programming works in general and don't really understand that there are multiple avenues that can be implemented to arrive at the same result. It is all a matter of preference and readability at that point.

0 Kudos
LisaCasey
Regular Contributor

Thank you very much for your suggestions and example code! I very much appreciate it!

In the end, Public Works decided to number the signs using a decimal, and as signs are inserted they will simply be numbered as 1.1 etc. And I like this solution as the signs retain their ID for life, and no re-numbering required! I am sure I will find a good use for your code in the future, and I am grateful for you sharing it with me.

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

The code above works regardless so long as the data type is numeric. Just FYI.

0 Kudos