Trigger idea for creating table records using ID formats

As of writing this Topic, generating new table records requires the user to either use Current Date and Time from the app, ‘randomstring()’ function or the expression editor. An idea that I was able to make work was to implement an expression that allows the developer to choose an ID format and have that ID autoincrement while still following the format of the ID. This could be IDs ranging ‘WO-000000’ to ‘WO-999999’.

For the aforementioned example I used the following expression:

‘WO-’ + left(‘000000’, 6 - len(totext(texttonumber(right(@Table Aggregation.Last ID , 6)) + 1))) + totext(texttonumber(right(@Table Aggregation.Last ID , 6)) + 1)

This expression was inspired from this post: Link to Post

The idea of this expression is that it takes advantage of the “texttonumber()” and “totext()” functions in order to construct the ID using the “Last ID” table aggregation.

If you wish to apply it to you needs, you can use the following template:

‘Prefix’ + left(‘00…’, n - len(totext(texttonumber(right(@Table Aggregation.Last ID, n)) + 1 ))) + totext(texttonumber(right(@Table Aggregation.Last ID, n)) +1)

Where “n” is the number you want your table records to have and the “prefix” is self explanatory.

If I was able to do this in the expression editor, I do believe it would be possible to make a trigger specific to the “Create Table Record by ID” trigger in order to generate IDs that correspond to the needs of the developer.

I do believe that a more substantial list of triggers for creating IDs for new table records would be beneficial as it would help new developers with table record triggers and even advanced app builders.

I’ll leave it at that. Thanks for reading my suggestion and I wish you all a good day and happy app building!

I can’t like this because it’s framed as a product suggestion, but thanks for sharing this—these templates will definitely be useful to folks in the future—and for adding the suggestion. It would definitely be easier to have pre-existing format options.

1 Like