Create SuiteScript of a saved search to fetch location details by passing an array of location names.

Consider the variable ‘locationArray’ as the array that contains location names.

let stringArr = '';
for (let i = 0; locationArray.length > i; i += 1) {
    stringArr += i > 0 ? ", '" + locationArray[i] + "', 'true'" : "'" + locationArray[i] + "', 'true'";
};let locationSearchObj = search.create({
    type: "location",
    filters:
        [
            [`formulatext: DECODE({name}, ${stringArr})`, "is", "true"],
            "AND",
            ["isinactive", "is", "F"]
        ],
    columns:
        [
            search.createColumn({ name: "name", label: "Name" }),
            search.createColumn({ name: "internalid", label: "Internal ID" })
        ]
});

Leave a comment

Your email address will not be published. Required fields are marked *