How to apply counter for each new record?

I have a data file which needs to compare fields and combine duplicate records. I now need to apply a counter for each combined record.
So if record 1 is only 1 - it would be 000001
Record 2 has 5 combined lines of data - this would now be 000002
Record 3 has 4 combined lines of data - this is now 000003 - and so on.

I have attached my template, Datamapper, and a counter created using Create new configuration - Generate counters; I am not able to combine the counter which is a Datamapper to my actual data.

New to this, so hopefully I have explained correctly.

The generate counter option is only intended for situations where you have no data and are printing directly from Connect Designer.

You’ll need to script a counter instead: Scripts: Manual Counter in Designer - OL® Learn

1 Like

Thank you for directing me to exactly what I needed! If I could ask one more question. :thinking:
How would I off set this to start the script on row 2 of my data, I need this to be seq 1?

Appreciate your quick reply, and again steering me in the right direction.

Or in the data mapper add a new field to an extract step and change its Mode to JavaScript and add this code.

('0000000000' + record.index).slice(-5);

record.index; will add a counter like, 1,2,3,4,5 etc. The padding of the zeros came from here. :wink:

Regards,
S

1 Like

Thank Sharne - this worked also!!! Love learning all of this.

Appreciate your quick reply, and steering me in the right direction

1 Like