They are simple scripts, but I have succeeded to migrate 3 without any problems.
But now I have run into a problem with the next one.
What I need to do is to read the contents of a CSV-file and map the different records to private data. It work fine in the other scripts I have migrated, but does not work here.
The contents of the file could be like this:
Code: Select all
DEU;<b>HTML</b>-line of text<br>which should be private data;
I am probably missing something simple.
Code: Select all
import * as fs from "fs";
async function jobArrived(s: Switch, flowElement: FlowElement, job: Job) {
let jobPath: string = await job.get(AccessLevel.ReadOnly) as string;
let inputFileText = await fs.readFileSync(jobPath, "utf-8");
await job.log(LogLevel.Info, "Filecontent: " + inputFileText);
let arrData = await inputFileText.split("\n");
await job.log(LogLevel.Info, "Antal sprog i CSV: " + arrData.length);
for( let i =0;i < arrData.length; i++) {
// Set to PD
let arrDataLine = await arrData[i].split(";");
let prefix = await arrDataLine[0];
await job.log(LogLevel.Info, "Prefix: " + prefix);
await job.log(LogLevel.Info, "Language: " + arrDataLine[0]);
await job.log(LogLevel.Info, "HTML: " + arrDataLine[1]);
await job.setPrivateData(prefix + "-strLanguage", arrDataLine[0]);
await job.setPrivateData(prefix + "-strHTMLline", arrDataLine[1]);
}
await job.sendToData(Connection.Level.Success);
}