OL Learn

How do I create a counter?

I would like to have a variable that counts a record. I currently set my boundary of a record by looking for a string, say the string “,10,”.

I would also like to use that same counter to create a barcode in the designer, but I cannot create a barcode without having a field in my datamapping.


In the DataMapper, you can add an Extraction Step, set the Mode to JavaScript and use the following code to get a 1-based incremental counter:


This counter is incremented for each new record.

Of course, if you want your counter to start at 1000, you’d use:

record.index + 999;

You get the idea… :slight_smile:


Is there a counter for a detailed table inside a record?
Record.index will give a number for the current record.
If inside this record there are a detailed table called invoice lines and a repeat looks through the lines.

Tried record.[DetaileTableName].index and record.DetailedTableName.index non of them works ?

Since you always extract your detail records inside a loop, you can simply use steps.currentLoopCounter.



This works for me!


steps.currentLoopCounter working perfectly