Sequences: Codes, IDs and indexes are not dead!

Avatar
Martin Večeřa

Gone are the days when computers needed all information to be indexed with a number. Well not gone, but the computers stopped bothering us – users – with these boring numbers.

Yet, we still love the IDs or codes to track individual records, or table rows if you wish. This allows us to easily share information with our colleagues, especially over the phone.

So the codes are very practical and can speed up our daily routines.

Most typically, project tasks have their codes. Like PRJ-1234.

It would not be very convenient for us to search for the most recently used number manually and add it to a newly created task. Let’s have a look at how Lumeer can do that automatically.

It is very simple. The desired outcome it as depicted below with the first column to be generated automatically.

We first open the Tasks table configuration.

And on the Rules tab, we create a new rule of type Blockly which allows us to set a value of a table row (also called document or record) upon its creation.

Here we built a simple rule that sets the attribute Code of the newly created document in the Tasks table to a string composed of a prefix LUMEER- and a value from a sequence called tasksSequence aligned to at least 4 digits.

A sequence is an ever increasing number that gets higher automatically every time it is read. We can save the rule and give it a try by creating a new task. Remember, we do not need to fill in the code.

The rule automatically filled in the code. However, the number is not correct. We already had two tasks, so we want the sequence to continue.

We can fix the added line manually and we want the next task to be assigned the code LUMEER-0004. Let’s open project configuration.

There we can see all the sequences we ever used in the rules. The counter is the last used number. So we want to set it to 3.

And let’s give it one more try in the table.

Et voila! Problem solved. Now you can easily ask your colleague to help you and carry on some work on the task LUMEER-0002.