Update
1 min
The following is an example of updating a Vendor where we are changing some of the fields. (See Vendor for all available fields). The NetSuite Vendor Id (internalId) is required to update the Vendor.
Note: You can only update one record at a time.
The response returns the complete vendor information, but we have shortened the response in our example for ease of reading.
// Create a Map to store all the data of a Vendor
Map<String, Object> nsVendor = new Map<String, Object>();
nsVendor.put('internalId', '32442');
nsVendor.put('currencyRecord', new Map<String, Object>{'internalId'=>'2'});
nsVendor.put('terms', new Map<String, Object>{'internalId'=>'5'});
nsVendor.put('category', new Map<String, Object>{'internalId'=>'4'});
nsVendor.put('email', '[email protected]');
nsVendor.put('phone', '7897734343');
// Initializing the Vendor Custom Fields
List<Object> vendCustomFieldList = new List<Object>();
Map<String, Object> vendCustomField1 = new Map<String, Object>();
vendCustomField1.put('fieldType', 'date');
vendCustomField1.put('scriptId', 'custentity_renewal_date');
vendCustomField1.put('value', String.valueOf(DateTime.newInstance(2020, 12, 26).getTime()/1000));
vendCustomFieldList.add(vendCustomField1);
Map<String,Object> vendCustomField2 = new Map<String, Object>();
vendCustomField2.put('fieldType', 'String');
vendCustomField2.put('scriptId', 'custentity_vendor_description');
vendCustomField2.put('value', 'Vendor for the Construction Materials');
vendCustomFieldList.add(vendCustomField2);
// Adding the Vendor Custom Fields
nsVendor.put('customFieldList', new Map<String, Object>{'customField'=>vendCustomFieldList});
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('vendors', new List<Object>{nsVendor});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'updateVendor');
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);