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.

Thanks.

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:

record.index;

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:

Hi

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.

Hi,

record.tables.detail.length;

This works for me!

Cheers,
fsh22

Thanks.
steps.currentLoopCounter working perfectly

Hi,
I need to add a sheet counter to the record.index to get a barcode like xxxxxcc, where xxxxx is the record.index and cc is the sheet counter incrementing from 00 to 99 for each sheet regardless of whether it belongs to the same record or not.
Each document (record) might have different number of pages.

thanks

Assuming you’re not using any separation or imposition settings, the record number effectively maps to the document number.

So ${document.nr} or ${document.sequence.set} would provide the current ‘record’ number.

Hi Alberts, what I’m missing is how to have a counter for all the front pages in the data, without resetting for each record. See following example
1000101
1000202
1000203
1000304
xxxxx is the record.index or ${document.nr} and as you can see 10001 has one sheet, 10002 two sheets, 10003 three sheets and yy counts the sheets .

Alright, just so you know, you can find all of these here.

So ${document.count.sheets} would give you the number of sheets in the current record.

And finally, for the sequence number at the end that resets at 99, that takes a bit of code to calculate. There’s a nice example here: Wrap around sequence - so close!

Many thanks! (just started today…)

We all start somewhere :smiley: Welcome aboard!

Hi @akispapa we are having the same issue of wanting to add a counter number to each page within each record rather than just the first page of each record.

Did you find a solution to this?

@russ_turner, can you please explain what kind of counter number you want to add to each page within each record? And do you want to add a counter number as in text or as in a barcode?

Are you looking for the available (Print Context) Pagination values Page Number and Page Count? If so, please note that you can add these a Print Context Section via respective “Page Number” and “Page Count” Toolbar options.

Pagination (Print Context only)

  • Page Number: Inserts a placeholder for the current page number
  • Page Count: Inserts a placeholder for the total number of pages in the current section.

Source: ‘Toolbars - PlanetPress Connect 2020.2 User Guide’

Hi Russ,
if you need the record index you can add a simple javascript in data mapper with the expression record.index; or you could ‘Add additional content’ in print options ${document.nr}.
For the sheet sequence you can add in print options ${sheet.sequence.job}

1 Like

@akispapa Thanks for this I will give it a whirl :+1: