Untitled
unknown
plain_text
a month ago
2.1 kB
3
Indexable
Never
public List<InventoryItem> GetAllInventoryItems() { NetSuiteService service; ItemSearch itemSearch = new ItemSearch(); ItemSearchBasic itemSearchBasic = new ItemSearchBasic(); List<Record> recordList = new List<Record>(); SearchStringField itemNameField = new SearchStringField(); SearchEnumMultiSelectField itemTypeField = new SearchEnumMultiSelectField(); string[] itemTypeContainer = new[] { "_inventoryItem" }; itemTypeField.@operator = SearchEnumMultiSelectFieldOperator.anyOf; itemTypeField.operatorSpecified = true; itemTypeField.searchValue = itemTypeContainer; itemSearchBasic.type = itemTypeField; itemSearch.basic = itemSearchBasic; service = ConnectionManager.GetNetSuiteService(); SearchResult response = service.search(itemSearch); recordList = new List<Record>(response.recordList); if (response.status.isSuccess) { recordList = response.recordList.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.ToList()); } } } } List<InventoryItem> inventoryItems = new List<InventoryItem>(); foreach (Record record in recordList) { try { inventoryItems.Add((InventoryItem)record); } catch { continue; } } return inventoryItems; }
Leave a Comment