How can I automatically generate a record number

Question on messaging by Pankaj Mathur, on 7/12/20: How can I automatically generate a record number, for example Invoice Number which will have a prefix “INV” and followed by a running number. Example - INV00001, INV00002, INV00003, INV00004, etc.

Hi there
This can be done by creating an automation script.

You will need a Settings module where you will keep the next invoice number. Therefore create a number field that will keep the data.

Create a record for the Settings module with the next invoice number defined, for example 1.

In the Invoice module, create a text field that will store the INV00001 value.

In the automation script that triggers on create on the module Invoice, you can then fetch the next Invoice number from the Settings module you created. And the save the new Invoice Number with the prefix to the text field in Invoice module.
For example:
newNumber = ‘INV’ + formatedNumber

Make sure to increment the next invoice number in the settings record.

In the version 2020.12 we are introducing field expressions that will make a task like this much easier.

hey @Lenny, when two or more invoices are created at the same time I would get the Steal Data error
for incrementing the number in the setting … any idea how to solve this?

The best I can think of on the spot would be to use an error handler where you could fetch the updated version and retry the operation.
If you could make those operations happen sequentially, that would probably be better (depending on your use case).

2 Likes

Hi, how can i achieve a sequential number or string with field expressions?
The docs for field-expressions are not ready yet.

My bad on the broken link; please refer to here and here

1 Like

Thanks. The Docs say:

Currently, you can only use values of the current record. References are not yet supported.

I think we will be able to make sequence referencing settings values. Reference other fields is a great feature.

1 Like

Dani,

Could you please elaborate on how you were able to solve this issue? Did you end up using the field expressions referencing the old value? I’m trying to achieve something very similar with an auto incrementing record number but wasn’t sure if it’s only achievable by workflow or if a field expression can manage.

If you want to have sequential, incrementing numbers, you’ll have to do the approach involving the workflow.

If you just care the number is incremental you could potentially get away with using field expressions.
You could use the current timestamp and convert it into MS.