Does anyone know how to do a simple search/get to ...
# suitetalkapi
z
Does anyone know how to do a simple search/get to get all stored sales orders? Right now I'm creating a SalesOrder RecordRef, and I must specify the internalId of the particular SalesOrder I am looking for. I would rather just pull all the Sales Orders we have (which is quite low, even in production)
j
would something like the following work?
Copy code
public static IEnumerable<Record> GetAllSalesOrders()
{
    List<Record> results = new List<Record>();

    TransactionSearch transactionSearch = new TransactionSearch
    {
        basic = new TransactionSearchBasic
        {
            type = new SearchEnumMultiSelectField
            {
                @operator = SearchEnumMultiSelectFieldOperator.anyOf,
                operatorSpecified = true,
                searchValue = new string[] { "_salesOrder" }
            }
        }
    };

    var session = LoginHelper2.Instance;

    if (session != null)
    {
        var response = session.search(transactionSearch);

        if (response.totalRecords > 0)
        {
            for (int i = 1; i <= response.totalPages; i++)
            {
                results.AddRange(response.recordList);

                if (response.pageIndex < response.totalPages)
                {
                    response = session.searchMoreWithId(response.searchId, i + 1);
                }
            }
        }
    }

    return results;
}
z
Thanks Jeff! I realize now that many of my attempts to get all the Sales Orders was failing, because I forgot that NetSuite sends search information in pages of 10.
j
sure thing. glad you got it working 🙂