I (think I) need to create a ‘Collection’, but I do not know enough JavaScript or even what to Google to find how to fix this. I am trying to iterate using a multi-instance subprocess on the elements in ordNumbers. ordNumbers is an array, but I believe I need it to be a Collection, but I do not know how to create a collection. Really would appreciate any help on this. Googling ‘how to create collection javascript’ does not yield useful results. I’ve seen a lot of things that look ‘close’, but nothing that has worked yet. Thank you!
Hello @AlphaGeek ,
as the script task in js is executed by a Java-embedded js engine, you can use
const ArrayList = Java.type("java.util.ArrayList");
const collection = new ArrayList();
passOneNumbers.forEach(number => collection.add(number));
execution.setVariable("collection", collection);
For reference, Java 15 and onwards can only use Javascript when embedding the Javascript engine.
Our distros contain the GraalVM JS engine: Java Interoperability
I hope this helps
Jonathan
2 Likes
Thank you, Jonathan! This is precisely what I was looking for.
1 Like