Printing Variable letters dependent on a field value.

Hi There

Within designer, I have two letters in my print contexts folder. I want to print each of these dependent on the value of a variable field in the data.

Can I do this? If so what is the best way to set it up. I have it working using snippets but I’m not sure if this is the best/correct way to go about it.

Thanks

Hi,

You can select different Print sections based on a field value using the following script:

// Simple approach to initially disable output for the Print sections

merge.template.contexts.PRINT.sections['Section 1'].enabled = false;
merge.template.contexts.PRINT.sections['Section 2'].enabled = false;
// Enable a print section based on the value of a data field
if(record.fields['flag'] == 'V1') {
    merge.template.contexts.PRINT.sections['Section 1'].enabled = true;
} else if (record.fields['flag'] == 'V2') {
    merge.template.contexts.PRINT.sections['Section 2'].enabled = true;
}

Context Print Sections are called Section 1 and Section 2, field that holds vaule is <flag> and the field values are “V1” and “V2”. First you need to turn off all sections (first part of the script) and then you can select which sections to use base on the values of <flag>.

You can select the control script in the bottom left (default settings) of the designer window when in template view. Click on the down arrow next to the Green “+” sign and select “Control Script”

Just delete what is already in there. Hope this is what you’re looking for.

Cheers!