the autonumber() function will generate a unique number by integer step for every unique value in another classification field. It does this by calculating the autonumber on Record creation.
Note: We would advise having the Field that contains the unique value to set the autonumber against to be a required field so that it must hold a value when the record is created.
An example would be to set an autonumber() per Location for a Project Tracker to result in values:
France - 1, United Kingdom - 1, France - 2, France - 3, United Kingdom - 2, ...
Note: In order to use the autonumber('Field') expression, the Field used as the Classification must be manual Input. If [Field] takes its value via expression then it cannot be used for the autonumber() function.
How to use the AutoNumber() function
To use this function it requires creating two Fields. One will be the Classification Field that can take a selection of values. In our example here
1st Field: Location - This field will hold your unique value for an auto-number to be generated from. E.g(United Kingdom, France, Spain etc..)
Note: The field must hold text based values.
2nd Field: Unique Location Reference in the Form "Location - 0"
[Unique_Value_Field_ID] + ' Optional Separator ' + autonumber('Unique_Value_Field_ID')
You will need to place the expression in the default value box and check the Process Default Value As Expression tick box.
[Unique_Value_Field_ID]: Our LocationField
'Optional Separator': This is used to differentiate and space out the autonumber generated number from our [Unique_Value_Field_ID]. Sample separators include: /, -, _ , 'blankspace'
autonumber('Unique_Value_Field_ID'): This is the autonumber method(). This method will generate an autonumber based on the 'field' you insert within the brackets.
So, in our scenario we have written our autonumber expression as
[Location] + ' - ' + autonumber('Location')
(Via default value as expression using auto-number expression)
We then add these two fields to a template and the app studio process is complete. We then move to workspace. An Autonumber expression will only run once on record creation. So:
- We create a record
- Choose a Location (our Unique Value Field)
- Save Record