Creation of Parent Custom Object Record
1 min
The following is an example of creating a Parent Custom Object Record where we are setting every possible field (See Custom Object for the available fields). The response will return the exact request data plus the new NetSuite Custom Object record Id (internalId) and 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', 'Parent Object Record');
nsCustomObject.put('isInactive', false);
// Initializing the Custom Object Custom Fields
List<Object> customObjectCustomFieldList = new List<Object>();
Map<String,Object> customObjectCustomField1 = new Map<String,Object>();
customObjectCustomField1.put('fieldType', 'string');
customObjectCustomField1.put('scriptId', 'custrecordphone');
customObjectCustomField1.put('value', '9809876567');
customObjectCustomFieldList.add(customObjectCustomField1);
Map<String,Object> customObjectCustomField2 = new Map<String,Object>();
customObjectCustomField2.put('fieldType', 'double');
customObjectCustomField2.put('scriptId', 'custrecord6');
customObjectCustomField2.put('value', 90.0);
customObjectCustomFieldList.add(customObjectCustomField2);
// 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', '17');
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);