OL Learn

Cloning section with details table data


I have problem with data mapper and designer inside Connect project.

I have data mapper with PDF input and repeat steps (for multiple extractions).
I don’t know how much pages we can have (1 or more)


I also have template where have 1 print section (Section will be always same), but I would like to replace data dynamically from details table.

For example I have document which has 2 pages (each page has different data)

  • Inside data mapper I have few extractions
  • Doing repeats until end of statements
  • Have details table for this RECORD which has 2 items inside

Inside template I am trying to clone my section using following script:

> var printSections = merge.template.contexts.PRINT.sections;
> var numClones = record.tables['detail'].length;
> if(numClones > 1) 
> {
> 	for( var i = 0; i < numClones - 1; i++)
> 	{ 
> 		var clone = printSections["Invoice"].clone();
> 		clone.name = "Invoice_clone_" + i; 
> 		printSections["Invoice"].addAfter(clone); 
> 		var pageNum = record.tables["detail"][i].fields.PageNumber;
> 		var docContent = record.tables["detail"][i].fields.DocContent;
> 	}
> }

And I am able to clone my section based on number of details table items, but for my clones, there are no data visible inside.


Can You help me please? Is there better way to do this?

Based on what you are showing us, I do not see the problem. Most likely you have some other scripts but with what you are showing, your script only does cloning.

Once the cloning is done, remember that any other scripts will be executed for each clone as they are seen as what they are…sections.

So if you have a script that replace a placeholder @something@ on a section, it will run for every clone, hence, you might have the same value on all clone for that placeholder.

You might need to define some kind of index (don’t use that name for it as it is a reserved word in Connect), as a global variable, in your Control Script. Use this global variable to keep track of each time the script is run so you can use it to tell the script which subrecord from your detail table you wish to use.

Hope that helps.

Hi Adam

I have similar situation. Can you pls post how you managed to apply the suggestion from Hamelj