Wrap around sequence - so close!

I’m using this code, that I nicked from another post:

${((sheet.sequence.job+999-1)%999)+1,000}

This starts the code at 001 and runs to 999 then back to 001.

I need the code to start at 000 and run to 999 what do I need to change?

try
('000' + ((sheet.sequence.job-1)%1000)).substr(-3)

Hi Johndoe

I’ve tried this and cant quite get to work, have tried:

(‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)
$(‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)
$(‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3);
${((‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)}
${((‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)};
$(‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)

I either get the above encode in the barcode as in (‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3) is the data in the barcode and not the data I want or an error like this:

LoggedApplicationException: There was an error running the output creation process caused by There was an error initiating to the output creation process caused by ApplicationException: Unable to create text expander for ${((‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)}
ApplicationException: Unable to create text expander for ${((‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)}
(SRV000041)

{“error”:{“status”:500,“message”:“LoggedApplicationException: There was an error running the output creation process caused by There was an error initiating to the output creation process caused by ApplicationException: Unable to create text expander for ${((‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)}\nApplicationException: Unable to create text expander for ${((‘000’ + ((sheet.sequence.job-1)%1000)).substr(-3)}\n (SRV000041)”,“parameter”:“”}}

@Barryosborne, please note that you can format date and number values. Search on the following page for “Formatting date and number values”: ‘Print output variables - PlanetPress Connect 2020.2 User Guide’

A option is to use one of the following:

  • ${sheet.sequence.job-1,000}
  • ${(sheet.sequence.job > 0 ? (sheet.sequence.job - 1) : 0),000}

Thanks Marten,

Both of these padded the number and started at 000 but it keeps counting past 999, I need it to get to 999 and then loop back to 000, 001, 002.

Thanks,

Here you are:
${((sheet.sequence.job-1)+1000)%1000,000}

This results in the following:
Page 1: 000
Page 100: 099
Page 1000: 999
Page 1001: 000
Page 1002: 001

and so on…
best regards
-i.

1 Like

Happy days that worked like a charm!

I am sorry this is pritty old topic but I would have some question to this.

I need to add counter into my output preset barcode which will always be incremeneted to each document page from “001” and when achieve “999” this will reset and start back from “001”

How to achieve that using output preset only?

Best regards

Hi @Odyn,

Have you already tried the code shared by Barryosborne in the original ‘post’?

I’m using this code, that I nicked from another post:

${((sheet.sequence.job+999-1)%999)+1,000}

This starts the code at 001 and runs to 999 then back to 001.

Oh sorry misslooked that today, need more coffe

Going to try this code at this moment.

Can You a bit explain please, why we are doing modulo 1000 ?

This code works fine and reset at 999 and starts back to 001

I found its not working in case if we have other(more) mailtypes.

For example if have Normals then it works fine.
But if have Midcounts also, it should start from 001 and count from begining

Any ideas?

Can you please let us know what you mean by “mailtypes”, “Normals” and “Midcounts”?

We are separating documents based on pages count and set them mail name like for example Normal, Midcount, Overcount etc.

Each group belongs to different pages range.
For example mailpiece from 1 to 5 pages going to Normals.

Inside output preset we are using separation by “job Segment”

Do you get the correct result when you use sheet.sequence.set instead of sheet.sequence.job?

sheet.sequence.set: Sheet number within the document set.
sheet.sequence.job: Sheet number within the job.

Source: ‘Print output variables - PlanetPress Connect 2021.1 User Guide’

If I use ${page.sequence.set,“00”}${set.count.pages,“00”}${((sheet.sequence.set+999-1)%999)+1,000} then always have 001 at the end.

Doesn’t seems to work, not event increment for single mail type (PDF output file)

He is incrementing sequence to 002 for second page inside sheet. Not to the next page.

I need to increment it always, inside files for each page. Do not related to sheet pages

Hi @Odyn,

What would you like to have as result? I suppose that you’re splitting the output into separated files by:

Seperation Options > Separate by Count:
Split: “At Exactly” Every: “5” [Sheets]

Where you would like to add the following barcode value to each page: 01 20 001, 02 20 002, 03 20 003, 04 20 004, 05 20 005, 06 20 001, 07 20 002, et cetera–except the spaces between the values? Otherwise, please let us know what you would like to have as result.

Yes we are splitting (doing some segmentation) and divide our output into some different types like Normal or Overcount.

So I would like to have 2D barcode on each page (its simplex)

Barcode payload need to contains:

CurrentPage TotalPages SpecialCounter

Where SpecialCounter will start from 001 and will be incremented up to 999 and rest back to 001.

Your way works fine if You have just 1 group of output (1 mailtype) but if You divide it then its not counting correctly in other types.

${var startVal = 000;
var sequence = (sheet.sequence.set + startVal) - 1;
sequence,000}

This is working for me in a test document where Size Grouping is enabled to split the job into document sets by sheet count. It’s resetting when I transition from 1 page to 2 page documents, and it transitions back to 000 when it reaches 999

Going to check Your solution right now.

We are not doing any size grouping in the way inside output preset.

We are grouping only based on DocMailtype and DocMailtypeSequence

So we group documents based on names like Normals, Midcounts, overcounts etc

Not working in my case.

Ok, well I noticed a flaw in my code anyway, it resets back to 0.

Anyway, your issue here is the placement of your group. You’ve got it at the Job Grouping level. Move it down to Document Set instead. Then use this:

${((sheet.sequence.set+999-1)%999)+1,000}

1 Like