Hi Phil,
Thanks for getting back to me.
Nope, not on a network share –
I’m sending a variable into JobInfo1, and writing out a text file using the following:
var origFn = automation.properties.OriginalFilename;
// OriginalFilename passed to datamapper from REST API json payload
if(origFn.indexOf(".")!== -1){
var fnNoExt = origFn.substring(0, origFn.lastIndexOf('.'));
}
else {
var fnNoExt = origFn
}
var workingPath = automation.jobInfo.JobInfo1;
// JobInfo1 passed to datamapper from REST API json payload
createdDirectory = workingPath+fnNoExt
// create directory if it doesn't exist
execute("cmd /c md "+workingPath);
var fileOut = openTextWriter(workingPath+fnNoExt+".dpf");
// ***** If column names need to be added as the first line in the output file,
// ***** comment out the next three lines (after adjusting the Labels
var Labels = 'Letter Code'+'\t'+'Courier ID'+'\t'+'Date'+'\t'+'Post Code';
fileOut.write(Labels);
fileOut.newLine();
//Go through all records to extract the fields value
var str="";
for (var i=0; i < data.records.length;i++){
letterCode = data.records[i].fields.Letter_Code;
courierID = data.records[i].fields.CourierID;
date = data.records[i].fields.Date;
postCode = data.records[i].fields.Add_5;
// concatenate the fields value with tabs to have TSV line (needed for .dpf)
str = letterCode + '\t' + courierID + '\t' + date + '\t' + postCode;
fileOut.write(str);
fileOut.newLine();
}
//Close file
fileOut.close();
All works fine if I send JobInfo1 a path that already exists eg. D:/aiw/aiw1/spool/default/DataOut
However, as soon as the execute command is uncommented again, no directory is created – doesn’t seem to matter if I use variables to initially code the path or hardcode a string.
As I said, works in debug on the server, but not through the API even with admin rights token.
All the best,
Tim