Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine NetSuite SuiteTalk PurchaseOrderItem Type

Tags:

netsuite

How can you determine if a PurchaseOrderItem is an Inventory Item or Noninventory Item?

Using NetSuite's SuiteTalk web service, I locate a specific PurchaseOrder based on a PO Number. From the purchaseOrder object, I can see the item list representing the purchaseOrderItems.

PurchaseOrderItem[] purchaseOrderItems = purchaseOrder.itemList.item;

I am able to enumerate the PurchaseOrderItems.

I would like to include some additional information such as whether each item is an Inventory Item or Noninventory Item. Also, for NonInventory Items, I need to determine if it is fulfillable. In NetSuite's UI can see this information by clicking the name of the item and looking at the "Can be fulfilled/received" (Field ID: isfulfillable).

Things I have tried:

I had some success with the following test code. It grabs the item.internalID and attempts to "get" a specific RecordType. I repeat this for all record types I am interested in. I am not comfortable with this solution.

I am hoping someone can point me in the right direction to solve this problem.

<!-- language: c# -->
// Look up inventory item
RecordRef recordRefInventoryItem = new RecordRef();
recordRefInventoryItem.internalId = poItem.item.internalId;
recordRefInventoryItem.type = RecordType.inventoryItem;
recordRefInventoryItem.typeSpecified = true;
ReadResponse responseInventoryItem = netSuiteService.get(recordRefInventoryItem);
if (responseInventoryItem.status.isSuccess)
{
    InventoryItem inventoryItem = (InventoryItem)responseInventoryItem.record;    
}

// Look up non inventory item
RecordRef recordRefNonInventoryItem = new RecordRef();
recordRefNonInventoryItem.internalId = poItem.item.internalId;
recordRefNonInventoryItem.type = RecordType.nonInventoryPurchaseItem;
recordRefNonInventoryItem.typeSpecified = true;
ReadResponse responseNonInventoryItem = netSuiteService.get(recordRefNonInventoryItem);
if (responseNonInventoryItem.status.isSuccess)
{
    NonInventoryPurchaseItem nonInventoryPurchaseItem = (NonInventoryPurchaseItem)responseNonInventoryItem.record;
bool isFulfillable = nonInventoryPurchaseItem.isFulfillable;
}

Follow up after bknights suggestion.

I created the following code to extract the internalIDs of the items, and perform a ItemSearchAdvanced search to qualify them. The following code returns a strongly typed result.recordList.

List<RecordRef> itemIds = new List<RecordRef>();
foreach (PurchaseOrderItem purchaseOrderItem in purchaseOrderItems)
{
    RecordRef recordRef = new RecordRef();
    recordRef.internalId = purchaseOrderItem.item.internalId;                    
    itemIds.Add(recordRef);
}

// configure a search to locate 'anyOf' itemIds
SearchMultiSelectField searchMultiSelectField = new SearchMultiSelectField();
searchMultiSelectField.searchValue = itemIds.ToArray();
searchMultiSelectField.@operator = SearchMultiSelectFieldOperator.anyOf;
searchMultiSelectField.operatorSpecified = true;

// tell the system we want 'internalID' 'anyOf' itemIds
ItemSearchBasic itemSearchBasic = new ItemSearchBasic();
itemSearchBasic.internalId = searchMultiSelectField;

// create an item search
ItemSearch itemSearch = new ItemSearch();
itemSearch.basic = itemSearchBasic;

// create an item search advanced
ItemSearchAdvanced itemSearchAdvanced = new ItemSearchAdvanced();
itemSearchAdvanced.criteria = itemSearch;

SearchResult result = NS.search(itemSearchAdvanced);

if (result.status.isSuccess)
{
    // results.recordList has strongly type items.  Yeah!
}
like image 785
scd Avatar asked Sep 19 '25 20:09

scd


1 Answers

What I tend to do is to collect all my item internal ids and then do a ItemSearchAdvanced with the list of item ids. This allows you to pull all the item types, sub-types and isFullfillable values for the item records.

The other way you can do this is to source those values into hidden custcol fields on the transaction.

like image 143
bknights Avatar answered Sep 23 '25 13:09

bknights