Using JS To Add Email Addresses
Posted: Thu Oct 10, 2019 7:25 pm
Rather than my spaghetti folder configuration to do this, I decided to try and conquer a script. The purpose of the script is to grab data from 1 (of several) fields submitted to a Submit Point by a Connector (XML job ticket), and use if/then's to determine which additional email address should be added to the job, which then simply goes to a Email Send configurator to send it.
What it's doing is nothing - it comes into the flow in a Submit point and just stops, not being acted on by the script which is the very next configurator in the flow - no errors, no nothing. I have a Flow element properties named "DatasetName" with just a single-line text for the Inline editor, and the "Default" property set to "Submit". I know it's hard to troubleshoot with this few of details, but first-off, does my script look right to perform this action?
Here's a truncated version of my code:
function jobArrived( s : Switch, job : Job )
{
var dataset = job.getDataset( s.getPropertyValue( "DatasetName"));
var xmlFilePath = dataset.getPath();
var xmlObj = new Document( xmlFilePath);
if (xmlObj.isWellFormed() == false) {
job.fail( "Bad XML");
return;
}
var mgrName = xmlObj.evalToString( "/field-list/field[6]/value");
job.log(1, mgrName);
if (mgrName === "Dr Pepper") {
job.addEmailAddress("info@mycompany.biz");
}
}
What it's doing is nothing - it comes into the flow in a Submit point and just stops, not being acted on by the script which is the very next configurator in the flow - no errors, no nothing. I have a Flow element properties named "DatasetName" with just a single-line text for the Inline editor, and the "Default" property set to "Submit". I know it's hard to troubleshoot with this few of details, but first-off, does my script look right to perform this action?
Here's a truncated version of my code:
function jobArrived( s : Switch, job : Job )
{
var dataset = job.getDataset( s.getPropertyValue( "DatasetName"));
var xmlFilePath = dataset.getPath();
var xmlObj = new Document( xmlFilePath);
if (xmlObj.isWellFormed() == false) {
job.fail( "Bad XML");
return;
}
var mgrName = xmlObj.evalToString( "/field-list/field[6]/value");
job.log(1, mgrName);
if (mgrName === "Dr Pepper") {
job.addEmailAddress("info@mycompany.biz");
}
}