Generators


Generators provide unique sequential numbering for many different uses, including Quote serial numbers, part numbers, etc.  Because Snap is a language that can process multiple transactions from many people at once, generators are the only reliable way in Snap to create:

  • a sequential number.
  • a unique number.

Generator Properties

Property Description
Name A name for the generator to easily identify it in rules.
Seed The number to start with. By default this is 1.
Increment

How to increment the number.

  • If the increment is 1, then the sequence seeded with 1 will be 1, 2, 3...
  • If the increment is 5, the sequence will be 1, 6, 11, 16...

How unique are generators?

 

As an administrator, you have access to 3 environments (Dev, Test, and Prod) in your organization.  Generators are unique within an environment, not across the entire org.

For example, if you have designed a "quote number" generator in DEV seeded at 101, and you generate 9 quotes in DEV, then the generator in DEV will produce 110 at its next call.  However, when that generator is deployed to TEST or PROD, it will have the same starting seed of 101 and will offer that number when first called.  This is intentional: you can use a generator many times in one environment during development or testing, and it will not cause a jump in the unique sequential numbering used in another environment, like production.

What if you want a unique number across all environments? For example, how can you ensure a quote PDF from your Test environment is not confused with an actual Production environment quote? Simply add more logic to your quote number. For example, consider this basic quote number function:

This naive code generates these quote numbers in the 3 environments.

dev Q-101, Q-102, Q-103...
test Q-101, Q-102, Q-103...
prod Q-101, Q-102, Q-103...



A better function includes the environment as a suffix, if it is not a production quote:

This better code generates these less-confusing quote numbers across the three environments.

dev Q-101-DEV, Q-102-DEV, Q-103-DEV...
test Q-101-TEST, Q-102-TEST, Q-103-TEST...
prod Q-101, Q-102, Q-103...


Was this article helpful?