need some help with my "newbie" question. I'm new to scripting with NodeJS and switch. I played around with it.
i copied the example from the documentation.
async function jobArrived(s, flowElement, job) {
const outConnections = flowElement.getOutConnections();
for (const connection of outConnections) {
if (job.isFile() && connection.getName() === 'Freigabe-Ordner') {
await job.sendTo(connection); // here it is
};
};
};
But this give me the error: await is only valid in async functions and the top level bodies of modules
What I'm doing wrong here? Can someone explain?
I see nothing wrong. Have you followed the correct procedure of creating the JavaScript code and linking to it from Switch Scripter and saving the script?
It gives you that error. Where? In the Switch Messages?
Yes, i think i linked it correctly. The errors shows up on switch internal webpage. And the file is routed to the problem folder. We have the Fall 2021 version installed by the way.
In the first of these two webinars you will hear multiple times: whenever you save the main.js script file, you also have to save the script in Switch Scripter for the reason that you mention: the script is cached.
In the second webinar it is explained how scripts can be developed in a different way by working with script folders (and in that case there is no need to save the script in Switch Scripter every time).