Hi,
I'm transmitting sales order to NetSuite from a propietary Website. This was working ok for InventoryItems and AssemblyItems until a new item type -Kit/Package- was added to the NetSuite configuration.
This is the c# method I'm using and it is oblivious it only handles InventoryItems and BOM. If I'd like to return the RecordRef for an item involved in the order -and handle all possible types- the only way I can imagine so far is to increase the try/catch cascade to include all item types being handled by NetSuite; however I think this is a very dirty solution. Is there any other workaround?
This is my code:
public RecordRef GetItemReference(string sku) { try { ItemSearch itemSearch = new ItemSearch(); SearchStringField itemEntityID = new SearchStringField(); itemEntityID.@operator = SearchStringFieldOperator.@is; itemEntityID.operatorSpecified = true; itemEntityID.searchValue = sku; ItemSearchBasic itemBasic = new ItemSearchBasic(); itemBasic.itemId = itemEntityID; itemSearch.basic = itemBasic; // Search for the customer entity SearchResult response = Service.search(itemSearch); //Check for the search result.. CheckNSStatus(response.status); if (response.recordList.Length > 0) { //declare the item reference RecordRef itemReference = new RecordRef(); //try with InventoryItem First... try { itemReference.type = RecordType.inventoryItem; itemReference.typeSpecified = true; itemReference.internalId = ((InventoryItem)(response.recordList[0])).internalId; } catch { //if here, then this is a "Assembly/Build of Materials" itemReference.type = RecordType.assemblyItem; itemReference.typeSpecified = true; itemReference.internalId = ((AssemblyItem)(response.recordList[0])).internalId; } return itemReference; } else { throw new Exception("Item not found"); } } catch (Exception ex) { throw new Exception("Error while looking up in Netsuite for Item with SKU=" + sku + ": " + Environment.NewLine + ex.Message, ex); } }Thanks in advance!R.Rod.