OL Learn

Vary the number of pages according to value in data

HI, I am trying to produce simple box labels, where the number of labels produced changes according to a value in the data. The data is csv, one line per set of labels. I have been able to change the quantity of pages by changing the record.copies in datamapper, but that does not allow me to number the box labels n of m. Is there any way of doing this in designer?

Hi @Chris_Tubb,

How are you creating these box labels? Are you creating these box labels by a Standard Script for example? If that’s corect, can you please share the JavaScript code you’re using to create these box labels?

I presume that by “[…] the box labels n of m” you mean the same as: "<current number> of <number of copies>", isn’t it? Do you want to add this value to the box label or to the page?

Starting with OL Connect 2021.1, the DataMapper allows you to modify fields in each record copy created through the record.copies value. Say, for instance, your field containing the box number is appropriately called “BoxNumber”. In that case, the following code would set the value for that field in each record copy:

record.copies = 6;
var oneRec = { BoxNumber : "" };

for(var i=0;i<record.copies;i++){
  oneRec.BoxNumber = "Box "+i+" of "+record.copies;

Note that for this to work, the BoxNumber field must either have a default value or already contain some extracted value.
See the online help for the record.setCopy() method for more information.

I only have an old pp7 file that uses presstalk at the moment. This works, but I was trying to bring everything up yo date by reproducing all my old pp7 workflows in pres designer. I have a designer file to produce a single label for each box but I am trying to work out how to make designer produce multiple pages using a field in the data.

Hi Phil, That looks like exactly what I need. Once I have updated to 2021 i will use it. Thank you

Hi Phil,
I’m going to sound like an idiot here, I have now updated to 2021, but I cannot figure out where to use the script you gave me. Any clues. I have tried to figure it out using the example in the manual you linked to, but still no clue. Sorry.

Think I have got it now. :slight_smile: