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"
Auto-number Expression:
[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.
Expression Breakdown:
[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
Result:
Make sure to click the 'Save' button when making any changes in order for them to be added to the next app version. Once you have made all the changes you need to an application you are then ready to publish it to workspace.
Note on Field Dependencies - Read more here
Field dependencies are by definition the other field(s) that are reliant on a given field, usually dependent fields are interlinked to one another by expressions and are indicated by an atom symbol. They are a crucial tool when looking to delete Fields within an App or, when it comes to understanding the structure and data flows of an App.
Comments
0 comments
Article is closed for comments.