Tom Hanson
Tom Hanson

Reputation: 935

SuiteScript 2.0 Search.Create filtering order status

I am trying to get all the sales orders of a particular customer via the search function.

var filters = [
   ["mainline", "is", "T"], "and",
   ["entity", "anyOf", idCustomer], "and",
   ["status ", "anyOf", "Pending Fulfillment"]
];

var searchQuery = search.create({
   "type": search.Type.SALES_ORDER,
   "filters": filters
});

salesorders = searchQuery.run().getRange({"start": 0, "end": 1000});

This throws an error,

enter image description here

How do I get a search like this working?

Upvotes: 1

Views: 1805

Answers (1)

michoel
michoel

Reputation: 3783

You have a stray space in your status filter; "status ", should be "status".

You will also need to change the filter value from "Pending Fulfillment" to "SalesOrd:B" in order for your search to return any values.

["status", "anyof", "SalesOrd:B"]

Upvotes: 2

Related Questions