Script task with javascript fails in Array method

Hi,

I have a Script task and I type the following javascript code:
(The process variable products_unhandled = [“A2”,“BD”,“VF3”] is ‘java.util.ArrayList’ type)

var products_unhandled = execution.getVariable("products_unhandled");
execution.setVariable("productSN", products_unhandled.shift());

I get error “shift is not a function”.

I want to take the first element and then remove it from the list.
What am I missing/doing wrong?

Thanks!

Print out to stdout product_unhandeled.getClass() to see what class the variable is. This will show the issue.

‘java.util.ArrayList’ is the class

If ArrayList is what is being returned (you are confirming that is what was returned when you do getClass()? ), then (i am no java expert), but does ArrayList have more “unique method names”: https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html

so you would use products.unhandled.add(myNewValue)

Yes, ArrayList from the println();
Indeed, I think a simple .remove(0) would do :wink: