Untitled

mail@pastecode.io avatar
unknown
csharp
5 months ago
1.5 kB
2
Indexable
public List<Customer> GetAllCustomers()
        {
            CustomerSearch customerSearch = new CustomerSearch();
            CustomerSearchBasic customerSearchBasic = new CustomerSearchBasic();

            List<Customer> recordList = new List<Customer>();

            SearchEnumMultiSelectField customerStage = new SearchEnumMultiSelectField();
            customerStage.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
            customerStage.operatorSpecified = true;
            customerStage.searchValue = new string[] { "_customer" };

            customerSearchBasic.stage = customerStage;
            customerSearch.basic = customerSearchBasic;

            SearchResult response = service.search(customerSearch);

            if (response.status.isSuccess)
            {

                recordList = response.recordList.Cast<Customer>().ToList();

                if (response.totalPages > 1)
                {
                    for (int i = 1; i < response.totalPages; i++)
                    {
                        service = ConnectionManager.GetNetSuiteService();
                        SearchResult _response = service.searchMoreWithId(response.searchId, i);
                        if (_response.status.isSuccess)
                        {
                            recordList.AddRange(_response.recordList.Cast<Customer>().ToList());
                        }
                    }
                }
            }

            return recordList;
        }
Leave a Comment