When we amend the code to explicitly add the comma...
# suitescript
k
When we amend the code to explicitly add the comma seperate externalid in the suitescript, it works
Copy code
if (datareceived.externalid != null) {
    const extId = datareceived.externalid.toString();
    if (extId.indexOf(",") > 0){
        log.debug("externalid has comma");                      
        formattedExtId = "\"" + extId.replace(",", "\",\"")+ "\"";
    } else {
        formattedExtId = extId;
    }
    log.debug("formattedExtId: " + formattedExtId);
    filterArray.push("AND");
    filterArray.push(["externalid", "anyof", "order1","order2"]);
    log.debug("externalid is provided: " + datareceived.externalid);
}
a
Copy code
if (datareceived.externalid != null) {
    let extId = datareceived.externalid.toString();
    
    if (extId.indexOf(",") > 0){
        log.debug("externalid has comma");                      
        extId = extId.split(",");
    }

    log.debug("extId : " + extId );
    filterArray.push("AND");
    filterArray.push(["externalid", "anyof", extId]);
    log.debug("externalid is provided: " + datareceived.externalid);
}
I think this should work
just make your incoming string list into an array with
.split
k
thank you both inc @Clay Roper, will give these a go!
a
if its still not working post logs, without knowing the data we're just guessing
k
received an error stating
Copy code
missing ; before statement
when the above is copy pasted
when we replace, 'let' with 'const' we are able to save the script.
got it working now 🙂 final code
Copy code
f (datareceived.externalid != null) {
                    const extId = datareceived.externalid.toString().split(",");
                    log.debug("extId : " + extId );
                    filterArray.push("AND");
                    filterArray.push(["externalid", "anyof", extId]);
                    log.debug("externalid is provided: " + datareceived.externalid);
                }
🎉 1
a
k well the code sample is reusing extid, so const wouldn't work, hence why i used let
oh yeah actually that's fine, you don't need to test for comma, cos split will just give you an array of size 1
🎯 1
k
Thanks for your help, defo a good starting point for us
👍 1