Global API
...
Requests
Customer

Create

1min
to create a customer in netsuite, use action as "createcustomer" and pass the customer data in the requestjson under "customers" note you can only create one record at a time the following is an example of creating a customer where we are setting every possible field (see customer docid\ hnjmkn99qxwdeafyyifsq for the available fields) the response will return the response back from netsuite, which includes the netsuite customer id (internalid), plus the newly created salesforce customer id (salesforceid) request // create a map to store all the data of a customer map\<string, object> nscustomer = new map\<string, object>(); nscustomer put('companyname', 'grand hotels & resorts ltd'); nscustomer put('category', new map\<string, object>{'internalid'=>'5'}); nscustomer put('customform', new map\<string, object>{'internalid'=>' 2'}); nscustomer put('currencyrecord', new map\<string, object>{'internalid'=>'1'}); nscustomer put('partner', new map\<string, object>{'internalid'=>'9'}); nscustomer put('pricelevel', new map\<string, object>{'internalid'=>'1'}); nscustomer put('receivablesaccount', new map\<string, object>{'internalid'=>'122'}); nscustomer put('subsidiary', new map\<string, object>{'internalid'=>'1'}); nscustomer put('startdate', datetime newinstance(2020, 12, 2) gettime()/1000); nscustomer put('terms', new map\<string, object>{'internalid'=>'5'}); nscustomer put('territory', new map\<string, object>{'internalid'=>' 5'}); nscustomer put('url', 'https //www grandhotel com'); // initialize the customer custom fields list\<object> custcustomfieldlist = new list\<object>(); map\<string, object> custcustomfield1 = new map\<string, object>(); custcustomfield1 put('fieldtype', 'select'); custcustomfield1 put('scriptid', 'custentityrating'); custcustomfield1 put('valuelookup', new map\<string, object>{'internalid'=>'2'}); custcustomfieldlist add(custcustomfield1); map\<string, object> custcustomfield2 = new map\<string, object>(); custcustomfield2 put('fieldtype', 'double'); custcustomfield2 put('scriptid', 'custentity decimal'); custcustomfield2 put('value', '76 89'); custcustomfieldlist add(custcustomfield2); // add custom segment field map\<string, object> custcustomfield3 = new map\<string, object>(); custcustomfield3 put('fieldtype', 'select'); custcustomfield3 put('scriptid', 'cseg lead source'); custcustomfield3 put('valuelookup', new map\<string, object>{'internalid'=>'3'}); custcustomfieldlist add(custcustomfield3); // add the customer custom fields nscustomer put('customfieldlist', new map\<string, object>{'customfield'=>custcustomfieldlist}); // initialize the customer addresses map\<string, object> addressbookaddress = new map\<string, object>(); addressbookaddress put('addr1','2334 n michigan avenue, suite 1500'); addressbookaddress put('city','chicago'); addressbookaddress put('state','il'); addressbookaddress put('country',' unitedstates'); addressbookaddress put('zip','60601'); map\<string, object> addressbook = new map\<string, object>(); addressbook put('addressbookaddress',addressbookaddress); addressbook put('defaultbilling',true); addressbook put('defaultshipping',true); addressbook put('isresidential',true); list\<object> addressbooklist = new list\<object>(); addressbooklist add(addressbook); nscustomer put('addressbooklist', new map\<string,object>{'addressbook'=>addressbooklist});&#x9; // initialize the requestjson data to be passed map\<string, object> requestjsonmap = new map\<string, object>(); requestjsonmap put('customers', new list\<object>{nscustomer}); string reqjson = json serialize(requestjsonmap); map\<string, object> reqobj = new map\<string, object>(); reqobj put('version', '1 0'); reqobj put('action', 'createcustomer'); reqobj put('requestjson', reqjson); // place a request to breadwinner global api map\<string, object> resp = breadwinner ns breadwinnernetsuiteapi call(reqobj); system debug(resp); response { action=createcustomer, timestamp=1606907168426, validrequest=true, version=1 0, responsejson={ "status" "200", "errors" \[], "customers" \[ { "vatregnumber" null, "url" "https //www grandhotel com", "title" null, "territory" { "type" null, "name" "default round robin", "internalid" " 5", "externalid" null }, "terms" { "type" null, "name" "1% 10 net 30", "internalid" "5", "externalid" null }, "taxitem" null, "subsidiary" { "type" null, "name" "parent company", "internalid" "1", "externalid" null }, "startdate" 1606847400, "stage" " customer", "salutation" null, "salesrep" null, "salesforceid" "a012w00000xup93aah", "resalenumber" null, "reminderdays" null, "receivablesaccount" { "type" null, "name" "accounts receivable", "internalid" "122", "externalid" null }, "pricelevel" { "type" null, "name" "base price", "internalid" "1", "externalid" null }, "phone" null, "parent" null, "nullfieldlist" null, "middlename" null, "lastname" null, "lastmodifieddate" 1606907165, "itempricinglist" null, "isperson" false, "isinactive" false, "internalid" "32342", "firstname" null, "fax" null, "externalid" null, "entitystatus" { "type" null, "name" "customer closed won", "internalid" "13", "externalid" null }, "entityid" "cust533at grand hotels & resorts ltd", "enddate" null, "email" null, "datecreated" 1606907165, "customform" { "type" null, "name" "standard customer form", "internalid" " 2", "externalid" null }, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "76 89", "scriptid" "custentity decimal", "internalid" "435", "fieldtype" null }, { "valuelookup" { "type" null, "name" "web", "internalid" "3", "externalid" null }, "value" null, "scriptid" "cseg lead source", "internalid" "559", "fieldtype" null }, { "valuelookup" { "type" null, "name" "acquired", "internalid" "2", "externalid" null }, "value" null, "scriptid" "custentityrating", "internalid" "42", "fieldtype" null } ] }, "currencyrecord" { "type" null, "name" "inr", "internalid" "1", "externalid" null }, "currencylist" { "currencyrecord" \[ { "currencyrecord" { "type" null, "name" "inr", "internalid" "1", "externalid" null } } ] }, "creditlimit" null, "creditholdoverride" " auto", "companyname" "grand hotels & resorts ltd", "category" null, "addressbooklist" { "replaceall" null, "addressbook" \[ { "label" "2334 n michigan avenue, suite 1500", "isresidential" true, "internalid" "29188", "defaultshipping" true, "defaultbilling" true, "addressbookaddress" { "zip" "60601", "state" "il", "internalid" null, "country" " unitedstates", "city" "chicago", "attention" null, "addrphone" null, "addressee" "grand hotels & resorts ltd", "addr3" null, "addr2" null, "addr1" "2334 n michigan avenue, suite 1500" } } ] }, "accountnumber" null } ] } }