the autnoumber() 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 old a value when the Record is created.
An example would be to set an autonumber() per Country for a Project Tracker to result in values:
France - 1, United Kingdom - 1, France - 2, France - 3, United Kingdom - 2, ...
Please Note: In order to use the autoNumber('Field') expression, the Field used as the Classification must be manual Input. If [Field] takes it's 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: Country - 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 Country Reference in the Form "Country-<AutoNumberGenerated>"
Auto-number Expression syntax:
[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 Country Field
'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
[Country] + ' - ' + autonumber('Country')
(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 Country (our Unique Value Field)
- Save Record