Skip to content

Counters and Number Ranges

Invoices, credits, cancellations and dunning reminders must have unique numbers to comply with legal regulations. In Draft status, these numbers are temporary and of no legal relevance. When finalizing invoices or dunning reminders, however, JustOn creates the unique and unalterable numbers based on defined counters.

Counter and number range concepts

JustOn implements counters using the custom setting Counters. The following fields are available:

Field Possible Values Description
Name Specifies the name of the counter, is to be referred to by the template.
Defines the interval after which the counter is reset. If empty, the counter is not reset.
Template [Year]
Specifies the pattern of the produced number. It may contain custom placeholders (defined for fields on the invoice, account, subscription, business entity, related invoice and email contact), and must define the minimum number of digits like {00000}. You can combine the placeholders and add any fix strings as necessary.
Use Account Counters (checkbox) true
If checked, creates a new number range for each account that uses this counter.
Start Count Optionally, specifies a start count. If set, the associated number range will start with the next number (<value> + 1). That is, if you want the number range to start with 5, the start count value must be 4.
JustOn evaluates the start count on number range creation and after reset.
If empty, defaults to 0.

The default counter as shipped with JustOn, for example, uses the following pattern template:


This produces invoice numbers of the following pattern:

201700001, 201700002, 201700003

The count increases each time an invoice is set Open and a new invoice ID is created.

The following table lists some examples.

Example Counter Template
2018Jan00001 [Year][MonthShort]{00000}
180100001 [Year:yy][Month:MM]{00000}
2018ACME00001 [Year][AccountAccountName]{00000}

By default, JustOn provides the following counters:

  • Default: A single counter used by default for generating all invoice, credit, cancellation or dunning IDs. This counter is assigned to the default invoice template.

    If you have more than one template or template details to cover specific needs, you can use an individual counter with each template or template detail. To this end, configure additional counters. If you use the dunning functionality, for example, configure a dunning counter first and assign it to the corresponding template detail.

    If the template or template detail does not define a counter, JustOn falls back to the counter set on the business entity. If the system cannot find a valid counter, it shows an exception.

  • Dunning Run: Used to count the individual dunning runs. The dunning run counter does not offer the reset feature and does not work with placeholders.

  • Subscription: Used to count the subscriptions. The subscription counter does not offer the reset feature and supports only a limited set of placeholders (account-related and built-in).

Each counter is associated to one or more number ranges. Number ranges are implemented as a custom object. They represent the groups of numbers to which the unique numbers created for an invoice, dunning reminder etc. belong. If a number range as required by the counter does not exist, JustOn creates one automatically with the count set 0.

With the counter field Reset set to YEARLY, JustOn creates a new number range for each year. Likewise it creates a new number range for each month if Reset is set MONTHLY, and every day if Reset is set DAILY. The reset feature can be combined with the setting Use Account Counters.

JustOn selects number ranges based on the counter defined for the invoice, the account of the invoice and the invoice date for day/month/year.

Number ranges include the following fields:

Field Description
Counter Name Specifies the name of the associated counter.
Counter Shows the current count for this number range. Equals the number of the last invoice.
Year Shows the year for this number range. Is empty if the counter is set to not reset.
Month Shows the month for this number range. Is empty if the counter is set to not reset or set to reset YEARLY.
Day Shows the day for this number range. Is empty if the counter is set to not reset or set to reset YEARLY or MONTHLY.
Account Shows the account for this number range. Is empty if the checkbox Use Account Counters on the counter is not selected.

Depending on your organization's requirements, you must create individual counters for business entities or for invoices, credits, cancellations or dunning reminders via corresponding templates.


When defining counters, be aware of the following considerations:

  • Special characters like -, ;, : etc. are likely to be removed from the reference string upon transaction processing by the banks. JustOn therefore recommends not to include these characters when defining the number pattern for the produced invoices in the field Template of the counter.
  • Account counters consume additional storage space in your org and may become difficult to handle with large numbers of accounts. JustOn therefore recommends to avoid using account counters, leaving the checkbox Use Account Counters of the counter unselected.

To create a new counter:

  1. In Setup, open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Counters.

  3. Click New.
  4. Specify the details as necessary.

    The mandatory fields include Name and Template.

    Optionally, set Reset, Use Account Counters or Start Count as necessary.

  5. Click Save.

    This creates the new counter and makes it available in business entities or templates.


Modifying existing counters immediately affects the current numbering.