Global API
...
Requests
Sales Order
Create
3min
to create a sales order in netsuite, use action as "createsalesorder" and pass the sales order data in the requestjson under "salesorders" note you can only create one record at a time the following is an example of creating sales order, where we are setting every possible field (see for sales order docid\ emqjiknclze b zi9pinn the available fields) the response will return the response back from netsuite, which includes the new netsuite sales order id (internalid), plus the newly created salesforce sales order id (salesforceid) request // create a map to store all the data of a sales order map\<string, object> nssalesorder = new map\<string, object>(); nssalesorder put('classification', new map\<string, object>{'internalid'=>'5'}); nssalesorder put('currencyrecord', new map\<string, object>{'internalid'=>'2'}); nssalesorder put('department', new map\<string, object>{'internalid'=>'2'}); nssalesorder put('discountitem', new map\<string, object>{'internalid'=>' 6'}); nssalesorder put('discountrate', ' 15'); nssalesorder put('entity', new map\<string, object>{'internalid'=>'362'}); nssalesorder put('memo', 'order 25'); nssalesorder put('otherrefnum', '4343399'); nssalesorder put('trandate', datetime newinstance(2020, 09, 07) gettime()/1000); // initialize the sales order custom fields list\<object> socustomfieldlist = new list\<object>(); map\<string,object> socustomfield = new map\<string,object>(); socustomfield put('fieldtype', 'select'); socustomfield put('scriptid', 'custbody customlist'); socustomfield put('valuelookup', new map\<string,object>{'internalid'=>'2'}); socustomfieldlist add(socustomfield); // add custom segment field map\<string,object> socustomfield2 = new map\<string,object>(); socustomfield2 put('fieldtype', 'select'); socustomfield2 put('scriptid', 'cseg lead source'); socustomfield2 put('valuelookup', new map\<string,object>{'internalid'=>'3'}); socustomfieldlist add(socustomfield2); // add the sales order custom fields nssalesorder put('customfieldlist', new map\<string,object>{'customfield'=>socustomfieldlist}); // initializing the sales order line items list\<object> lineitemlist = new list\<object>(); map\<string, object> lineitem = new map\<string, object>(); lineitem put('description', 'a weapon for shooting arrows'); lineitem put('item', new map\<string, object>{'internalid'=>'239'}); lineitem put('quantity', 1); lineitem put('price',new map\<string, object>{'internalid'=>' 1'}); lineitem put('rate', '999'); // initialize the line item custom fields list\<object> licustomfieldlist = new list\<object>(); map\<string, object> licustomfield = new map\<string, object>(); licustomfield put('fieldtype', 'boolean'); licustomfield put('scriptid', 'custcol checkbox'); licustomfield put('value', 'true'); licustomfieldlist add(licustomfield); // add custom segment field map\<string,object> licustomfield2 = new map\<string,object>(); licustomfield2 put('fieldtype', 'select'); licustomfield2 put('scriptid', 'cseg lead source'); licustomfield2 put('valuelookup', new map\<string,object>{'internalid'=>'3'}); licustomfieldlist add(licustomfield2); // add the sales order line item custom fields lineitem put('customfieldlist', new map\<string, object>{'customfield'=>licustomfieldlist}); lineitemlist add(lineitem); // add the line items to sales order map\<string, object> solineitemlist = new map\<string, object>(); solineitemlist put('item', lineitemlist); nssalesorder put('itemlist', solineitemlist); // initialize the requestjson data to be passed map\<string, object> requestjsonmap = new map\<string, object>(); requestjsonmap put('salesorders', new list\<object>{nssalesorder}); string reqjson = json serialize(requestjsonmap); map\<string, object> reqobj = new map\<string, object>(); reqobj put('version', '1 0'); reqobj put('action', 'createsalesorder'); 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=createsalesorder, timestamp=1606471494020, validrequest=true, version=1 0, responsejson={ "status" "200", "errors" \[], "salesorders" \[ { "tranid" "12320000000000117", "trandate" 1599417000, "total" 984 0, "taxtotal" 0 0, "subtotal" 999 0, "subsidiary" { "type" null, "name" "parent company", "internalid" "1", "externalid" null }, "status" "pending approval", "shippingcost" null, "salesrep" null, "salesforceid" "a0d2w0000092rckea2", "otherrefnum" "4343399", "nullfieldlist" null, "memo" "order 25", "location" null, "lastmodifieddate" 1606471491, "itemlist" { "replaceall" null, "item" \[ { "unitsdisplay" null, "taxrate1" "0 0", "taxcode" { "type" null, "name" "vat in\ undef in", "internalid" "5", "externalid" null }, "tax1amt" 0 0, "shipmethod" null, "shipgroup" null, "serialnumbers" null, "revrecstartdate" null, "revrecschedule" null, "revrecenddate" null, "rate" "999 00", "quantityremaining" null, "quantityreceived" null, "quantitybilled" 0 0, "quantity" 1 0, "price" { "type" null, "name" null, "internalid" " 1", "externalid" null }, "ponum" null, "orderline" null, "onhand" null, "location" null, "line" 1, "jobname" null, "itemreceive" null, "itemname" null, "itemisfulfilled" null, "item" { "type" null, "name" "bow", "internalid" "239", "externalid" null }, "grossamt" 999 0, "expectedreceiptdate" null, "description" "a weapon for shooting arrows", "department" null, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "1", "scriptid" "custcol gh line no", "internalid" "175", "fieldtype" null }, { "valuelookup" null, "value" "12320000000000117 72960", "scriptid" "custcol gh so line id", "internalid" "200", "fieldtype" null }, { "valuelookup" { "type" null, "name" "web", "internalid" "3", "externalid" null }, "value" null, "scriptid" "cseg lead source", "internalid" "559", "fieldtype" null }, { "valuelookup" null, "value" "false", "scriptid" "custcol checkbox", "internalid" "443", "fieldtype" null } ] }, "createpo" " dropshipment", "costestimatetype" null, "costestimate" null, "classification" null, "amount" 999 0 } ] }, "internalid" "54352", "handlingcost" null, "externalid" null, "exchangerate" 1 0, "entity" { "type" null, "name" "21 atherton grocery", "internalid" "362", "externalid" null }, "discounttotal" 15 0, "discountrate" " 15 00", "discountitem" { "type" null, "name" "partner discount", "internalid" " 6", "externalid" null }, "department" { "type" null, "name" "sales", "internalid" "2", "externalid" null }, "customform" { "type" null, "name" "custom sales order 2", "internalid" "121", "externalid" null }, "customfieldlist" { "customfield" \[ { "valuelookup" { "type" null, "name" "b", "internalid" "2", "externalid" null }, "value" null, "scriptid" "custbody customlist", "internalid" "458", "fieldtype" null }, { "valuelookup" { "type" null, "name" "web", "internalid" "3", "externalid" null }, "value" null, "scriptid" "cseg lead source", "internalid" "559", "fieldtype" null }, { "valuelookup" null, "value" "false", "scriptid" "custbody checkbox", "internalid" "272", "fieldtype" null } ] }, "currencyrecord" null, "currencyname" "us dollars", "createdfrom" null, "createddate" 1606471488, "classification" { "type" null, "name" "corporate sales", "internalid" "5", "externalid" null } } ] } } pass billing and shipping addresses when passing an existing netsuite customer address as the billing/shipping address for a sales order, refer to the sample code below request // add the customer's existing address as sales order's billing address nssalesorder put('billaddresslist', new map\<string, object>{'internalid'=>'7825'}); // add the customer's existing address as sales order's shipping address nssalesorder put('shipaddresslist', new map\<string, object>{'internalid'=>'7826'}); when passing a custom billing/shipping address specific to sales orders only, you can refer to the sample code provided below request // initialize the sales order's custom billing address map\<string, object> billingaddressdetails = new map\<string, object>(); billingaddressdetails put('attention','plum a'); billingaddressdetails put('addressee','plum abc'); billingaddressdetails put('addr1','2334 n michigan avenue, suite 1500'); billingaddressdetails put('addr2','near abc block'); billingaddressdetails put('city','chicago'); billingaddressdetails put('state','il'); billingaddressdetails put('country',' unitedstates'); billingaddressdetails put('zip','60601'); // add the sales order's custom billing address nssalesorder put('billingaddress', billingaddressdetails); // initialize the sales order's custom shipping address map\<string, object> shippingaddressdetails = new map\<string, object>(); shippingaddressdetails put('attention','plum x'); shippingaddressdetails put('addressee','plum xyz'); shippingaddressdetails put('addr1','525 s lexington ave'); shippingaddressdetails put('addr2','near xyz block'); shippingaddressdetails put('city','burlington'); shippingaddressdetails put('state','nc'); shippingaddressdetails put('country',' unitedstates'); shippingaddressdetails put('zip','27215'); // add the sales order's custom shipping address nssalesorder put('shippingaddress', shippingaddressdetails);