question

Larry Dietz avatar image
Larry Dietz asked

string.split

I am trying to pass a delimited string to cloudscript, and want to split that string into an array within the cloudscript.

Seems like it ought to be pretty simple and straight forward, but I am having some issues.

Below is the relevant code from my cloudscript...

When this executes, I receive the below error in the playstream...

Any idea what I am doing wrong?

"Error": {
            "Error": "JavascriptException",
            "Message": "JavascriptException",
            "StackTrace": "TypeError: Cannot read property 'split' of undefined\n    at handlers.AddInventory (1F06-.CloudScript.js:324:26)"
        }
    var Qtys = [];
    var Qty = ""; 


    if (args && args.hasOwnProperty("QTYs"))
        Qty = args.QTYs;


    log.info("QTY" + Qty);


    Qtys = Qty.split(";", -1);
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Larry Dietz avatar image
Larry Dietz answered

Nevermind. I figured it out. I had to declare the array and split the string in the same line of code. Declaring first at the top just didn't work.

Here is the working code...

if (args && args.hasOwnProperty("QTYs"))
        Qty = args.QTYs;


    var Qtys = Qty.split(";", -1);
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.