QIE uses a 3rd party library to correctly parse CSV. This library has some modes that it can be configured for. Currently we support 2 modes:
QuoteMode.ALL
or
QuoteMode.MINIMAL
We use ALL in the case where quotes around everything is the desired result, and we use "MINIMAL" when quotes are not desired. MINIMAL usually results in no-quotes, however certain situations can still trigger quotes to be placed around fields.
Quotes are added when the cell ends with a space or any character with a lower numeric value i.e. tab or newline.
So in the case above because 'Test 3 is ' ends with a space when no value is provided, quotes are placed around the field.
There are multiple work-arounds for when this occurs. Heres a few for the example above:
1. Provide a dummy value
// validate values aren't empty:
if (!message.checkNodeExists('/test3') || StringUtils.isEmpty(message.getNode('/test3'))) {
message.setNode('/test3','N/A');
}
var template = "Test 1 is {m:/test1},Test 2 is {m:/test2},Test 3 is {m:/test3}";
var templateOutput = qie.evaluateTemplate(template);
message = qie.createCSVMessage('', false, '"', ',', 'UTF-8', false);
qie.debug(templateOutput);
message.setNode('/', templateOutput);
qie.warn(message.getNode("/"));
2.
Replace placeholder
var template = "Test 1 is {m:/test1}|**|,Test 2 is {m:/test2}|**|,Test 3 is {m:/test3}|**|";
var templateOutput = ("" + qie.evaluateTemplate(template)).replace(/\s*\|\*\*\|/g, '');
message = qie.createCSVMessage('', false, '"', ',', 'UTF-8', false);
message.setNode('/', templateOutput);
qie.warn(message.getNode("/"));