Update
1 min
The following is an example of updating the Custom Object Record, where we are changing some of the fields. (See Custom Object for all available fields). The NetSuite Custom Object Record Id (internalId) is required to update the Custom Object Record.
Note: You can only create one record at a time.
The response returns the complete Custom Object Record information, but we have shortened the response in our example for ease of reading.
// Create a Map to store all the data of a Custom Object
Map<String, Object> nsCustomObject = new Map<String, Object>();
nsCustomObject.put('internalId', '808');
nsCustomObject.put('name', 'Custom Record-2 update');
nsCustomObject.put('isInactive', true);
// Initializing the Custom Object Custom Fields
List<Object> customObjectCustomFieldList = new List<Object>();
Map<String,Object> customObjectCustomField = new Map<String,Object>();
customObjectCustomField.put('fieldType', 'string');
customObjectCustomField.put('scriptId', 'custrecord172');
customObjectCustomField.put('value', 'Custom Field Value-1 update');
customObjectCustomFieldList.add(customObjectCustomField);
// Adding the Custom Object Custom Fields
nsCustomObject.put('customFieldList', new Map<String,Object>{'customField'=>customObjectCustomFieldList});
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('customObjectRecords', new List<Object>{nsCustomObject});
requestJSONMap.put('customObjectID', '11');
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'updateCustomObjectRecord');
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);