Hi all, anyway for me to get “Pending Fulfillment”...
# suitescript
k
Hi all, anyway for me to get “Pending Fulfillment” sales order via restlet. I need to get all the internal ID of sales order that is Pending Fulfillment
b
your 2 primary options are the N/query Module or the N/search Module
👍 1
k
Copy code
var mySearch = search.create(
            {type:'SalesOrder', filters: [['status', 'is', 'Pending Fulfillment']]
           });
           
           mySearch.run().each(function(result){
            log.debug(result)
            
           });
Hi Battk, How can i achieve this using search?
I can only get 1 single item via search Module
b
Go through the documentation of ResultSet.each
returning nothing is the same as returning false
Usually its wrong to use a ResultSet if you dont know how many search results you are interested in
You should be using a paginated search instead
k
Hi battk, but my result is empty during log.debug
b
what does your code look like now
k
The same code but it throws an empty array
Let me recode my syntax to match the documentation you sent me
because even with resultSet it won't work because result it self is empty?
Copy code
mySearch.run().each(function(result) {
    var entity = result.getValue({
        name: 'entity'
    });
    var subsidiary = result.getValue({
        name: 'subsidiary'
    });
    return true;
});
This code won't work if my result is empty. I am not sure if
Copy code
var mySearch = search.create(
            {type:'SalesOrder', filters: [['status', 'is', 'Pending Fulfillment']]
           });
           
           mySearch.run().each(function(result){
            log.debug(result)
            
           });
Is the proper syntax
Is filters: [['status', 'is', 'Pending Fulfillment']] a correct syntax?
b
honestly everything is wrong
the filters arent using internal ids
you have no columns
you are making mistakes on top of mistakes
dont expect changing one thing to give you a better result
you should start at the N/search code examples
the search module behaves very similarly to saved searches in the ui
once you get the basics of creating and running simple searches in code
the usual approach is to create the search in the ui, then load the search in code so you can inspect its filters and columns
that way you know what ids you should be using
k
For the UI is it under Reports -> New Search?
b