1// Create a Map to store all the data of a Custom Object
2 Map<String, Object> nsCustomObject = new Map<String, Object>();
3 nsCustomObject.put('name', 'other object record');
4 nsCustomObject.put('isInactive', false);
5
6// Initializing the Custom Object Custom Fields
7 List<Object> customObjectCustomFieldList = new List<Object>();
8
9 Map<String,Object> parentObjectLookupfield= new Map<String,Object>();
10 parentObjectLookupfield.put('fieldType', 'string');
11 parentObjectLookupfield.put('scriptId', 'custrecord239');
12 parentObjectLookupfield.put('value', '2626');
13 customObjectCustomFieldList.add(parentObjectLookupfield);
14
15 Map<String,Object> customObjectCustomField1 = new Map<String,Object>();
16 customObjectCustomField1.put('fieldType', 'string');
17 customObjectCustomField1.put('scriptId', 'cusrecord240');
18 customObjectCustomField1.put('value', 'Hello World');
19 customObjectCustomFieldList.add(customObjectCustomField1);
20
21 Map<String,Object> customObjectCustomField2 = new Map<String,Object>();
22 customObjectCustomField2.put('fieldType', 'string');
23 customObjectCustomField2.put('scriptId', 'custrecord241');
24 customObjectCustomField2.put('value', '9');
25 customObjectCustomFieldList.add(customObjectCustomField2);
26
27// Adding the Custom Object Custom Fields
28 nsCustomObject.put('customFieldList', new Map<String,Object>{'customField'=>customObjectCustomFieldList});
29
30// Initializing the RequestJSON Data to be passed.
31Map<String, Object> requestJSONMap = new Map<String, Object>();
32 requestJSONMap.put('customObjectRecords', new List<Object>{nsCustomObject});
33 requestJSONMap.put('customObjectID', '196');
34 String reqJSON = JSON.serialize(requestJSONMap);
35
36Map<String, Object> reqObj = new Map<String, Object>();
37 reqObj.put('version', '1.0');
38 reqObj.put('action', 'createCustomObjectRecord');
39 reqObj.put('requestJSON', reqJSON);
40
41// Placing a request to Breadwinner Global API
42Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
43System.debug(resp);