OL Learn

Split based on Detail.Table field



I know you can split pdf output using the job presets/output presets, but I am struggling with if the split is based on a detail.table variable? I do not see the detail table variables in the list when setting up the job preset. Is this something that can be accomplished?

I am looping through a detail table to gather all the forms and applying the variables to all the documents for output. I need to split the final output into individual records based on the detail table record.


Can you provide a fuller explanation? Conceptually, details are details OF A RECORD, and each record produces a document. So it seems like you need to split an individual document up, and I don’t think that’s supported.


Hello, thank you for your response. Yes, I have been told that splitting a record on a detail table element is not supported.

The process is a single xml record with multiple pdfs being pulled in to make up that one record. The pdfs are stored in a detail table, so Detail Record 1 is PDF1, Detail Record 2 is PDF2 and so on.

Since I am unable to export as multiple pdfs based on the Detail Record, I would like to add the variables on the pages for the particular detail record. I have a script that is looping through the forms in a detail table. This works great, but I would like to add the variables for the detail table to the page like you describe below, but I can’t seem to figure out how to do that.

Data Example:

Detail Record 1:
Form: ABC.pdf (4 pages)
Form_ID: ABC
Store_Location: location1

Detail record 2:
Form: EFG.pdf (2 pages)
Form_ID: EFG
Store_Location: location2

Detail Record3:
Form: LMN.pdf (1 page)
Form_ID: LMN
Store_Location: location1

I would like my output pdf to look like this with the content in parenthesis to be hidden text or maybe text in white?

Page 1 (ABC – location1)
Page 2 (ABC – location1)
Page 3 (ABC – location1)
Page 4 (ABC – location1)
Page 5 (EFG – location2)
Page 6 (EFG – location2)
Page 7 (LMN – location1)

When I try to add variables in the loop, it is concatenating all the Form_ID’s and Store locations into one element on the first page so it doesn’t show on all individual pdf pages or it is overriding so I only get the last variables in the Detail table?


I think an approach you should consider, if each PDF in the data file should generate its own final document, is to alter the data map so that each PDF node becomes a top-level record rather than a detail record.

Is that possible?


I don’t think it is? The rest of the xml is actually the data that would fill all the variables in each of the pdfs. If I would go that route, I would need to somehow store the variable pieces of the xml is another file possibly, split the xml based on the pdf xml node and then concatenate the variable detail file back to each individual pdf xml. I was hoping there was an easy way, like splitting on a detail.table field. :frowning:


I think the approach of storing the variable data (you could use Watch Automation Variables for this if there aren’t too many, or an XSLT processor to alter the structure of your XML to store/repeat the variable nodes inside the PDF nodes (put them under the same repeating node), is the best approach.


How about creating a section and clone this section for each detail record? It would require a Control Script to create section clones. The Control Script API allows you to set the background images of these clones programmatically too. Check the script below. This approach would still add the information to a single document.

Note that I would not take this approach for large data (e.g. many detail records). Ideally you would model your data so that each document becomes a single record (rather than a record in a detail table). In that case you would benefit from running multi merge engines.


var printSection = merge.template.contexts.PRINT.sections['Section 1'];	
var data = record.tables.detail;

for (var i in data) {
	let clonedSection = printSection.clone();
	clonedSection.background.source = BackgroundResource.RESOURCE_PDF;
	clonedSection.background.url    = "file:///C:/sample_data/images/pdf/" + data[i].fields.store_location;
	printSection.addAfter( clonedSection );

printSection.enabled = false;