Skip to content

Sequences

Number sequences are common in most CRM solutions. Some typical use cases are Ticket number, Quote number and Project number.

How to use them

  1. Navigate to Lime Admin ➡️ System ➡️ Sequences.
  2. Define the starting number and the increment.
  3. Use the "Get sequence number" step in an Automation.

Sequences are created in Lime Admin. You specify the Starting Number and the Increment.

Sequences with prefixes and suffixes

Sometimes the use case for you sequence requires a specific prefix, suffix or padding. In those cases its perfect to

  1. Get Sequence Number
  2. Add Prefix using Formula
  3. Save the Value

Here is an example of using a Sequence with a prefix in an Automation:

Using sequences from Python

It is possible to generate sequence numbers in python customizations. The function for getting the next value from a sequence is defines as follows:

def get_next_sequence_value(
    connection: sqlalchemy.engine.Connection, name: str
) -> int:

It can be used for example in Custom LimeObject, like so:

from lime_type import get_next_sequence_value

class Company(LimeObject):
    """
    Sets a new number on each company.
    """
    def before_update(self, uow, **kwargs):
        super().before_update(uow, **kwargs)
        if (self.is_new):
            company_number = get_next_sequence_value(
                self.application.connection, "My Company Number Sequence"
            )
            self.get_property("CompanyNumber").value = company_number

Good to know

Sequence numbers can, under certain circumstances, skip 50 numbers. For instance: 1134, 1135, 1185, 1186... If this is not acceptable, it is suggested to use other solutions for sequences. For instance, if you have a recieving system that relies on this sequence, let that system create the sequence via an api call.

Sequences cannot be deleted. If you wish to "start over", you need to create a new Sequence.