Repeat in datamapper or Loop in Workflow?

Hi,

I have a field with a number. based on that number I have to print out X barcodes.

What is the best solution and do you have an example?

I am looking into repeat for datamapper, but I can’t get it to work.

I also looked into loop in Workflow, but I can’t seem to grab the variable.

here is a sample packagefile. I think repeat is the way, but I can’t get it to work.

https://learn.objectiflune.com/qa-blobs/8799900335498227064.ol-package

The principle is explained here: https://learn.objectiflune.com/howto/create-detail-table-linear-data-structure/

Try this:

Attached datamapper file was created in the latest v2018.1.6. So you need to be in this version to open the file. Or you can recreate in your version using the below steps:

Repeat step
Repeat Definition
	Repeat type: until statement is true
	Maximum number of iterations on each line: parseInt(record.fields.repeat);

Condition: 
	Left Operand
		Based on: JavaScript
		Expression: steps.currentLoopCounter;
	Operator: is equal to		Invert condition: not selected
	Operand types: Integer
		Based on: JavaScript
		Expression: parseInt(record.fields.repeat);

GoTo step:
	From: Top of record
	Move to : 1

Alternatively, if you simply want to print X copies of the same record, then you don’t need a Repeat step. At the top of your data mapping config, just after the Preprocessor step, add the Action step with the Expression:

record.copies=data.extract('repeat',0);

New DM Config here.

great! thanks! I needed your last config :slight_smile: record.copies=data.extract(‘repeat’,0);