I need to create a control script for multiple letter ids. Below is the script that I have, and is working, for two letter ids. I’m just not sure of the syntax for more than two letter ids.
Any assistance is appreciated. Thank you! Jennifer.
// replace var Lettertype = record.fields.xxxxxxxxx; with your field name
var lettertype = record.fields.LetterNumber;
if (lettertype == ‘VA30’){ merge.template.contexts.PRINT.sections[‘VA75’].enabled = false; }
Essentially, what you need to do at this point is to disable all of the sections, other than the one which has the same name as the value of your record. The easiest way to do this is with a loop. Assuming that the value of lettertype always has a corresponding section then the following code should work perfectly:
// Start by getting a list of the current sections in the template
var printSections = merge.template.contexts.PRINT.sections;
// Loop through each of these sections
for (var i = 0; i < printSections.length; i++) {
var section = printSections[i];
// If the section's name (VA30, VA75) is equal to the field value
if(record.fields.LetterNumber == section.name) {
section.enabled = true;
} else {
section.enabled = false;
}
}
Here is another way, without for loops, but more typing. I think it is easier to read however.
First create a control script, needs to be the first script then disable all sections like this:
// Page_Control Script
var CurLang = record.fields.LANGUAGEPREFERENCEGRO;