Condition Email Content

Hi there,

For print content, setup a conidition script can help the version swtiching base on data.
How about Email? Is there any easy way for Email content switching?
Or have to create different branch in workflow?

Cheers

Hi @CainZ,

Do you know from the input data whether something should be printed or e-mailed? Can you please share some information about the input data, whether it’s a XML file or a TXT file for example?

I assume that it might be worth checking the following forum post: ‘How to dynamically select a context? (link)’

Hi @Marten

Thanks for reply, the data is text.
Which have over 10 different templates of Email. I need to change templates base on the supplied data.
However when I right click on Email conetent there is nothing like Print section which can make a condifiton
image

image

I’ll check our backlog to see why this option is not available (sorry for the inconvenience). For now you could create a custom Control script to toggle the correct section.

var summerMessage = merge.template.contexts.HTML_EMAIL.sections['Summer'];
var springMessage = merge.template.contexts.HTML_EMAIL.sections['Spring'];

summerMessage.enabled = false;
springMessage.enabled = false;

if( 'summer' === record.fields.promotion ) {
	summerMessage.enabled = true;
} else {
	springMessage.enabled = true;
}

The script first disables all email messages (my sample has two email sections). Subsequently it uses a script to enable the one stated in the data where the springMessage is the fallback.

Erik

Hi @Erik ,

Thanks for the updating.
Then what should you do when you create email content in workflow?
It ask you to select the Email section as fix

Thanks

I believe you can enter a dummy section name, this way the template will fallback to the default message. I expect the script to take precedense.

If you override the email section in a control script, the section specified in Workflow is ignored - so it doesn’t matter what you enter there.

Thanks so much for your help @Sander @Erik