Create
1 min
To create a Custom Object Record in NetSuite, use action as "createCustomObjectRecord" and pass the Custom Object Record data in the requestJSON under "customObjectRecords".
Note: You can only create one record at a time.
The following is an example of creating a Custom Object Record where we are setting every possible field (See Custom Object for the available fields). The response will return the response back from NetSuite, which includes the NetSuite Custom Object Record Id (internalId), plus the newly created Salesforce Custom Object Record Id (salesforceID)
// Create a Map to store all the data of a Custom Object
Map<String, Object> nsCustomObject = new Map<String, Object>();
nsCustomObject.put('name', 'Custom Record-2');
nsCustomObject.put('isInactive', false);
// 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');
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', 'createCustomObjectRecord');
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);