The code below is vb.net. "_nsService" is a little helper object.
The code below works great for Purchase Orders. If I try to use it for Sales Orders, the TranId will display. When I try to access the CustomFieldList object, I get "Object reference not set to an instance of an object." The same will occur for ItemList. Again, these objects work for PO's but not SO's
I know the wsdl definitions for PO and SO are different but when I look at the soap response, the definitions for CustomFieldList and ItemList look the same.
Would anyone be able to help?
'Init generic transaction search Dim Search As TransactionSearch = New TransactionSearch() Search.basic = New TransactionSearchBasic() 'tempInternalId is an InternalId of a Purchase Order or a Sales order Dim tempInternalId As String 'tempInternalId = "3756" 'PurchaseOrder InternalId tempInternalId = "3755" 'SalesOrder InternalID 'Init the internalid for the search Search.basic.internalId = _nsService.extSearchRecordRefEquals(tempInternalId, Nothing) 'Init object for result and obtain search result Dim searchResult As SearchResult searchResult = _nsService.search(Search) ' Call the search webservice 'Did we get a decent response If searchResult Is Nothing Or _nsService.extResponseOK(searchResult) = False Then MsgBox("Response from NetSuite Failed") Else 'Init tempTransaction as either a PO or SO 'Dim tempTransaction As PurchaseOrder Dim tempTransaction As SalesOrder 'tempTransaction = DirectCast(searchResult.recordList(0), PurchaseOrder) tempTransaction = DirectCast(searchResult.recordList(0), SalesOrder) 'TranId works for either a PO or SO MsgBox("TranId=>" & CStr(tempTransaction.tranId) & "<") 'customFieldList.Length words for PO but not SO MsgBox("tempTransaction.cfl.length=" & tempTransaction.customFieldList.Length) End If