What is the most efficient way to set up a workflow when you have a Design document that includes several pages or a page per Section but you only like to compose 2-3 pages in the workflow depending on data input.
It’s important that it should be easy to maintain, add new pages/Sections or make changes in the design of the document.
I had a similar task at time ago, but in that case the input data did not contain which pages should be printed then a used a control script lite this one to be able to control which pages should be printed.
Using a control Script like this one in the Desinger and Set jobs and info and variables in the workflow does not be the best way to solve the workflow when I have the data what pages should be printed.
If you have data which decides which sections to print, you could try something like:
var record.fields.enabled_sections = 'Section 1|Section 3|Section 4';
var enabled_sections_list = record.fields.enabled_sections.split('|');
var printSections = merge.template.contexts.PRINT.sections;
for (var i = 0; i < printSections.length; i++) {
var section = printSections[i];
var enabled = enabled_sections_list.indexOf(section.name) != -1;
section.enabled = enabled;
}
this way you should be able to control the sections per record without worrying about new sections
The input data has columns ID, ID2 and ID3, for each record the data in those columns determin which Sections should be used.
Input data could look like this, not all records has 3 pages
Name;ID;ID2;ID3
Steven;2;4;5
Frank;1;;4
Whould it be easiest to name each Sections so it correspond to the input data, and use a control script
/Thomas
Sorry, I made a mistake while copy/pasting the code. But it wouldn’t have worked anyway, given the new information you just posted. So if I understand correctly, using your sample data, Steve would get a document with Sections 2, 4 and 5 while Frank would only get Sections 1 and 4.
If that’s correct, then the code would look something like this:
?The code assumes your sections are named “Section 1”, “Section 2”, etc. The code loops through all sections and checks if the number of each section is found in any of the ID, ID1 and ID2 fields. If it is, the corresponding section is enabled otherwise it is turned off.