Global API
...
Custom Object
Create Custom Object with chil...
Complete Parent and Child record creation
1min
below is an example of creating a parent and child record in one action request // 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('skipdml', true); reqobj put('requestjson', reqjson); // placing a request to breadwinner global api map\<string, object> resp = breadwinner ns breadwinnernetsuiteapi call(reqobj); system debug(resp); / we need to pass the internal id of the record created above as an attribute to create the child record we also want to check the status of the parent record to make sure it was successfully created / // parse the "responsejson" string into a map, "responsejson" is a key from response map\<string, object> responsejson = (map\<string, object>)json deserializeuntyped((string)resp get('responsejson')); // extract the "status" field from the parsed map string status = (string)responsejson get('status'); // extract the "customobjectrecords" list where internalid is present in the response list\<object> customobjectrecords = (list\<object>)responsejson get('customobjectrecords'); // check if the list is not empty and has at least one record string parentinternalid; if (!customobjectrecords isempty()) { // extract the first record from the list map\<string, object> firstrecord = (map\<string, object>)customobjectrecords\[0]; // extract the "internalid" field from the first record parentinternalid = (string)firstrecord get('internalid'); } if(parentinternalid != null && status == '200'){ // create a map to store all the data of a custom object 	map\<string, object> nscustomobject = new map\<string, object>(); nscustomobject put('name', 'other object record'); 	nscustomobject put('isinactive', false); 	// initializing the custom object custom fields list\<object> customobjectcustomfieldlist = new list\<object>(); map\<string,object> parentobjectlookupfield= new map\<string,object>(); parentobjectlookupfield put('fieldtype', 'string'); parentobjectlookupfield put('scriptid', 'custrecordpre0007'); parentobjectlookupfield put('value', parentinternalid); customobjectcustomfieldlist add(parentobjectlookupfield); map\<string,object> customobjectcustomfield1 = new map\<string,object>(); customobjectcustomfield1 put('fieldtype', 'string'); customobjectcustomfield1 put('scriptid', 'custrecord194'); customobjectcustomfield1 put('value', 'auto mobiles'); customobjectcustomfieldlist add(customobjectcustomfield1); map\<string,object> customobjectcustomfield2 = new map\<string,object>(); customobjectcustomfield2 put('fieldtype', 'string'); customobjectcustomfield2 put('scriptid', 'custrecord193'); customobjectcustomfield2 put('value', 'safari'); 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', '12'); 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); } else{ list\<object> errors = (list\<object>)responsejson get('errors'); system debug(errors); }