Runtime Parameter Question

Hi,

I have a duplex section in my template. I want to switch duplex on and off, so in the template I created a runtime parameter called duplex, set to boolean. In a control script I have:

if(merge.template.parameters.duplex == false){
	merge.context.sections.Mail.sheetConfig.duplex = false;
	merge.context.sections.Mail.sheetConfig.omitEmptyBackside = true;
}

When I print from the template to test this, by setting the parameter to default false, it works as expected. (Same with setting it to false and selecting Preview) But when doing so in Workflow it does not work. (Even tried the All in One plugin)

Am I doing something wrong?

Regards,
S

Hi @Sharne,

Please check what the Data Type is of the Runtime Parameter “duplex”. You can do this by adding for example the following code to your Control Script:

logger.info("Data Type of \"duplex\": " + (typeof merge.template.parameters.duplex));

After that you can open the log file of the Merge Engine to check the result of the logger.info() function. I’m asking you this because the value is probably a String instead of a Boolean.

Another option to test this is by replacing the condition by:
merge.template.parameters.duplex == "false".

Hi Marten,

Thanks for the quick reply. I added the logger code to the script and ran a test in debug, but could not find a log containing said info. Looking at the Messages in the template itself did result in “Data Type of “duplex”: boolean”. I changed the IF statement as you suggested and it now works. So another case of Connect template versus Workflow interpreting things differently.

Regards,
S

You will have to check the log file of the Merge Engine when you would like to check the log messages, created by using the logger.info(), logger.warn() or logger.error() function in a Connect Template.

Can you let me know please what kind of value (Data Type) are you assigning to the Runtime Parameter “duplex” on the Workflow side?

First time I’m using parameters, so I just added it like pictured below. These parameters are actually going to reduce processing time for many of my Workflow processes. No need to execute data mapping multiple times anymore.

I can see that the Data Type of the Runtime Parameter “duplex” is String when it does have the Value ‘false’ or ‘“false”’ on the Workflow side so I suppose that you can still use the same value on the Workflow side but that you’ve to update your JavaScript code on the Template side to:

if (merge.template.parameters.duplex == "false") {
	merge.context.sections.Mail.sheetConfig.duplex = false;
	merge.context.sections.Mail.sheetConfig.omitEmptyBackside = true;
}

P.S. I’m a little bit confused about the Data Type on the Workflow side. Does anyone else knows how to make it an Boolean on the Workflow side? Because on the Connect Designer side you have the option to change the Type to: String, Number, Date or Boolean.

All parameters, job Infos and variables in Workflow are always strings. That’s one of the limitations. So your suggestion to use

 merge.template.parameters.duplex == "false"

is the proper one.

The Designer allows you to set a type for the Runtime Parameters because other applications (which, contrary to Workflow, would presumably be able to use typed parameters) could call the Content Creation engine.

1 Like