Can anyone shed any light as to why the below woul...
# suitescript
k
Can anyone shed any light as to why the below would not work on a UE BeforeSubmit? Works in a client script.
Copy code
var searchResults = search.create({
                         type: "salesorder",
                         filters: [["name","anyof",custIntID], "AND", ["item","anyof",itemIntID], "AND", ["type","anyof","SalesOrd"], "AND", ["closed","is","F"]],
                         columns: [search.createColumn({name: "trandate", sort: search.Sort.DESC}), "rate"]}).run().getRange({start:0, end: 1});
j
variables
custIntID
and/or
itemIntID
are likely numbers instead of strings. In my experience search filter expressions only play nice with strings. It works in the client because in the client
search.create
is implemented differently. It delegates the search to a script handler endpoint via an http request. The http request probably converts all parameters to strings.
e
What is the error you are getting?
k
{"type":"error.SuiteScriptError","name":"SSS_INVALID_SRCH_OPERATOR","message":"An nlobjSearchFilter contains an invalid operator, or is not in proper syntax: item."
@jkabot I get what your saying but i must be getting the wrong value from my itemIntID variable.
j
You can log the value and also log
typeof itemIntId
The suitescript 2.0 api is really inconsistent in terms of when it returns a string or an number for internalids
You might be able to fix it by using
String(itemIntId)
k
Yeah i think it is because another function not working correctly wither.