Upland OL User community

Sequence number in addition to page numbers

Hi All,

I have a requirement to include a sequence number on print pages. I’ve attached an example document to try to explain the issue.

The sequence number needs to increment for every print page so, in my example, section 1’s sequence number would be 00000001, record 2 00000002…record 6 (page 1) 00000006 (page 2) 00000007, record 7’s number would then be 00000008 etc.

Any help is appreciated.



demo file.OL-template (18.0 KB) demo file.OL-datamapper (57.4 KB)

How about this:

var globals = globals || { sequenceNo: 1 };
Handlebars.registerHelper("sequenceNo", () => formatter.number(globals.sequenceNo++, "00000000"));

Hi Sander,

Thanks for the responce. That seems to be the same as the page number in that it increments for each page within a record but not for the record as well.

In the example I gave record 1 would have a number 00000001, record 2 00000002 etc.Where the record generates multiple pages then the number should increment for every page where the handlebar is present. I basically need to number to carry over to the next record.



Hi John,

Create a new field in your data mapper and set it to Javascript then use the below:

// The below is realy all you need

// Although Using a pad function will add leading 0's
function pad(n, width, z){
 z=z || '0';
 return n.length >= width ? n : new Array(width - n.length + 1).join(z)+n;

1 Like

Hi Alex,

Thank you for coming back so quickly. Unfortunately, the record index will not do. The record could generate 1 page, or it could generate 10 pages, I have no way of knowing.

If record 1 were to generate 5 pages, then the pages would be numbered 00000001 to 00000005. Record 2 would then start at 00000006. If record 2 had 2 pages, then they would be numbered 00000006 and 00000007. Record 3 would start 00000008 and so on.

Hope this is clear.

Thanks again,


Ah ok, so to confirm you want sheet number throughout an entire run? So for example you process a file with 1654 pages you would start at 1 and the last number would be 1654 a bit like a book?

In your example yes, like a book. 1654 would be the total number of pages but, if some of the records generated multiple pages, then there could be say 1500 records that generate those 1654 pages.

This is for a sequence number by the way. I am actually using page numbers within the records as well, but that’s already sorted using # of ##.


If I understand it right, you have to add that sequence number as additional text in the output.

If you want to increment the counter per page, you can use the output variable ${page.sequence.job} or ${format.formatNumber(page.sequence.job,'00000000')} to have leading zeros
If you want to increment the counter per sheet, you can use the output variable ${sheet.sequence.job} or ${format.formatNumber(sheet.sequence.job,'00000000')} to have leading zeros

Hello @johnfowler,

What is the end goal for the sequence numbering?
We ask so we can see if there are any workaround to reach the same goal.
At the moment, the multi-threading features of Connect seems to prevent having a global incremental like you want.

Hello @johnfowler,

Are the Batch and Batch-end split sheet or will they have their own content from the data?

Hi All,

Thank you so much for the feedback. This was document I mocked up so that I wouldn’t be using any confidential data. The addresses are not real.

On the real template, the batch pages have their own content and are used by the print room to organise the stacks of paper by date and picking row etc. The danger is that the stack gets knocked over and they have to restack some of the pages. I don’t think Thomas’ suggestion will be suitable as we did not want to count the batch pages.

The end goal is that the we are able to restack the paper correctly. We have page numbers that identify a customer/order/page but we also need to be able to quickly see if the pages should be near the top or bottom of the stack. It may not be practical if we have a table full of paper that gets knocked over but, if we can fix minor spills, then this is well worth the effort.


Hi John,

I ran some tests with the slipsheets funcationality and additional content options added by output presets (inspired by conversations with my colleague @Manuel). This basically works, the sequence numbering skips the slipeheets but unfortunately it starts on the banner page. This is what I did:

I removed the slipsheet section from the template, these will be added by the output engine. As slipsheets are added per 10 documents I needed to group documents in job segments (1 per 10 documents) using a jobpreset. The output engine can add slipsheets after job segments.

To achieve this I added a data field in the data mapping configuration, this field increases a batch number per 10 documents. See the image below:

This batch ID is used in the jobpreset to group documents (e.g. creating the batches of 10 documents).

Next I enabled the slipsheet in an output preset.

Sequence number
The sequence number is added by the output preset. For this I used the Additional Content option and added the following text variable: ${page.sequence.job, “00000000”}

This number is not shown on the slipsheets but again unfortunately it is shown on the banner page.

This is the closest I can get,


1 Like

Maybe approach it from a slightly different angle

First, move your original conditions for banner/batch pages from the template to the datamapper. In the datamapper use those conditions to create copy of the records.
By default each record will have REC_TYPE field set to ‘DOC’. When condition for start/end of batch are met, create a copy of the record and mark them as ‘B_S’ (batch start) or ‘B_E’ (batch end) accordingly.
Then, in the template make sections conditional based on the REC_TYPE value. Actual sequencing will happen in the presets.

In job preset, create a job segment metadata for a page counter and set it to 0. Also add REC_TYPE as metadata on the document level so the output preset can distinguish between documents and banners.

In the output preset, add the segment metadata page counter as text but output and increase it only on document pages:
if (document.metadata.REC_TYPE == ‘DOC’) {
segment.metadata.pageCounter = parseInt(segment.metadata.pageCounter) + 1;
} else {
rec_type_and_segment_counter.OL-jobpreset (3.6 KB) rec_type_and_segment_counter.OL-outputpreset (19.9 KB) rec_type_and_segment_counter_2022.2.OL-datamapper (59.2 KB) rec_type_and_segment_counter_2022.2.OL-template (18.0 KB)

1 Like