Objectif Lune joins Upland Software.Learn more >

Back to all How-tos

Manual Counter in Designer!

While the Generate Counter script is really useful for things like Raffle Tickets, it’s unfortunately unusable if you already have your own Data File as it cannot complement that data file automatically.

The script below can be used instead of the Generate Counter, and uses the current record index to calculate the current counter value. Note that we added one additional bonus feature to this script : you can “reset” it every nth step! Pure Awesomeness.

To use this script simply add a placeholder to your page (such as @counter@ ) and create a Script with the @counter@ Text selector. Then paste the code below in the script editor:


// Beginning value
var startValue = 1;
// Increment by this number every step
var incrementValue = 1;
// Reset to startValue after this number of steps (use 0 for no reset)
var stepToReset = 0;
// To pad the counter, set the min width: 
var counterWidth = 0;
// If padding, set the character to pad with: 
var paddingChar = "0";
// Add an optional prefix: 
var prefix = "";
// Add an optional suffix: 
var suffix = "";

var counter = record.index;
if(stepToReset) counter = ((record.index-1) % stepToReset) + 1;
if(incrementValue) counter = (counter * incrementValue)-incrementValue;
if(startValue) counter = startValue + counter;
if(counterWidth) counter = pad(counter, counterWidth, paddingChar);
counter = prefix + counter + suffix;


// Stolen from StackOverflow
function pad(n, width, z) {
  z = z || '0';
  n = n + '';
  return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;

Leave a Reply

Your email address will not be published. Required fields are marked *

All comments (2)

  • Russ Turner

    Hi how do we apply the counter to the additional pages that flow over from within each record?

    Just something I’ve been struggling to do 😀

    Kind regards,


    • Erik van den Heuvel

      Hi Russ,

      It would be matter of adding an abs box to a master page and insert the stated placeholder there. Master pages are repeated as a background for all pages. By default Section 1 is linked to Master page 1.

      You can create multiple master pages with different setups (for example holding a box for to show the page number). The link between the section and master page is handled in the Sheet Configuration dialog which you can access when right clicking a section in the Resources panel or from the Section menu.

      Hope this is of some help,