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', 'Parent 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> customObjectCustomField1 = new Map<String,Object>();
10 customObjectCustomField1.put('fieldType', 'string');
11 customObjectCustomField1.put('scriptId', 'custrecordphone');
12 customObjectCustomField1.put('value', '9809876567');
13 customObjectCustomFieldList.add(customObjectCustomField1);
14
15 Map<String,Object> customObjectCustomField2 = new Map<String,Object>();
16 customObjectCustomField2.put('fieldType', 'double');
17 customObjectCustomField2.put('scriptId', 'custrecord6');
18 customObjectCustomField2.put('value', 90.0);
19 customObjectCustomFieldList.add(customObjectCustomField2);
20
21// Adding the Custom Object Custom Fields
22 nsCustomObject.put('customFieldList', new Map<String,Object>{'customField'=>customObjectCustomFieldList});
23
24// Initializing the RequestJSON Data to be passed.
25Map<String, Object> requestJSONMap = new Map<String, Object>();
26 requestJSONMap.put('customObjectRecords', new List<Object>{nsCustomObject});
27 requestJSONMap.put('customObjectID', '17');
28 String reqJSON = JSON.serialize(requestJSONMap);
29
30Map<String, Object> reqObj = new Map<String, Object>();
31 reqObj.put('version', '1.0');
32 reqObj.put('action', 'createCustomObjectRecord');
33 reqObj.put('requestJSON', reqJSON);
34
35// Placing a request to Breadwinner Global API
36Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
37System.debug(resp);