Hello, I have issues with my search. ``` function ...
# suitescript
s
Hello, I have issues with my search.
Copy code
function IsNewOrder(orderId) {
     s = search.create({
        type: search.Type.SALES_ORDER,
        filters: [search.createFilter ({ 
            name:'otherrefnum',
            operator: search.Operator.CONTAINS,
            values: orderId})],
        columns: ['otherrefnum']
    }).run().getRange({
        start: 0,
        end: 10
    });//should only be one
}
The filter seems to return the first line of all my list of record of Sales Order. It seems that the filter 'otherrefnum' doesn't match the parameter orderID that is a value I get by using getValue in a fieldChanged function. So I don't known why the search always return the first line of all my transaction and not the matching orderId. Have you ever have this issue before ? Thank you !
b
otherrefnum
is the
PO/Check Number
filter in the ui
dont use text operators on numbers
s
@battk what operators should I use ? to do a search for duplicate of PO number in sales order ?
when I go to the otherrefnum I can put letters on the field so maybe it is a free form text ?
b
make your search in the ui first
you need to familiarize yourself with how the
PO/Check Number
and
PO/Check ID
filters work and the differences between the two
s
How can I make my search in the UI ? I have to do a search.save() ?
b
make a transaction search un the ui
make it do what you want
then convert that search to code
s
I don't understand what do you mean by converting the search to code ? I have to create a search on the saved search report then use the id of this search to do the search in my code ?
b
make the search in the ui first
you are using the filter wrong in code
the ui wont let you do that
s
ok so I have to save a saved search on my UI and then use it in my code that is it ?
b
i suspect you would know how to change the code after you learn how the filter works
s
ok
b
but if you don't, my recommendation is to load the search you created in the ui in code so that you can inspect.log the filters so you can then copy it in code
s
ok I will work on that ! Thank you !