Update
1 min
The following is an example of updating an Item where we are changing some of the fields. (See Item for all available fields). The NetSuite Item Id (internalId) and Item Type (itemType) are required to update the item.
Note: Breadwinner supports multiple item updates in one request, but it is still in the beta stage.
The response returns the complete Item information, but we have shortened the response in our example for ease of reading.
Pass skipDML as true in the request to skip the DML operation in Salesforce.
Map<String, Object> nsItem = new Map<String, Object>();
nsItem.put('internalId', '7718');
nsItem.put('itemType', 'nonInventorySaleItem');
nsItem.put('displayname', 'Leather Jacket');
nsItem.put('location', new Map<String, Object>{'internalId'=>'10'});
nsItem.put('salesDescription', 'Black Color Leather Jacket');
// Initializing the Item Custom Fields
List<Object> itemCustomFieldList = new List<Object>();
Map<String, Object> itemCustomField = new Map<String, Object>();
itemCustomField.put('fieldType', 'select');
itemCustomField.put('scriptId', 'custitem_category');
itemCustomField.put('valueLookup', new Map<String, Object>{'internalId'=>'2'});
itemCustomFieldList.add(itemCustomField);
Map<String, Object> itemCustomField1 = new Map<String, Object>();
itemCustomField1.put('fieldType', 'boolean');
itemCustomField1.put('scriptId', 'custitem_available');
itemCustomField1.put('value','true');
itemCustomFieldList.add(itemCustomField1);
// Adding the Item Custom Fields
nsItem.put('customFieldList', new Map<String, Object>{'customField'=>itemCustomFieldList});
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('items', new List<Object>{nsItem});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'updateItem');
reqObj.put('skipDML', false);
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);