Global API
...
Requests
Purchase Order

Create

1min
to create a purchase order in netsuite, use action as "createpurchaseorder" and pass the purchase order data in the requestjson under "purchaseorders" note you can only create one record at a time the following is an example of create purchase order where we are setting every possible field (see purchase order docid 8aljk2kh41ujg328klgjy for the available fields) the response will return the response back from netsuite, which includes the new netsuite purchase order id (internalid), plus the newly created salesforce purchase order id (salesforceid) request // create a map to store all the data of a purchase order map\<string, object> nspurchaseorder = new map\<string, object>(); nspurchaseorder put('classification', new map\<string, object>{'internalid'=>'5'}); nspurchaseorder put('currencyrecord', new map\<string, object>{'internalid'=>'1'}); nspurchaseorder put('department', new map\<string, object>{'internalid'=>'2'}); nspurchaseorder put('duedate', datetime newinstance(2020, 12, 31) gettime()/1000); nspurchaseorder put('entity', new map\<string, object>{'internalid'=>'30440'}); nspurchaseorder put('shipto', new map\<string, object>{'internalid'=>'362'}); nspurchaseorder put('memo', 'po 12'); nspurchaseorder put('otherrefnum', '4343399'); nspurchaseorder put('trandate', datetime newinstance(2020, 09, 07) gettime()/1000); // initializing the purchase order custom fields list\<object> pocustomfieldlist = new list\<object>(); map\<string, object> pocustomfield = new map\<string, object>(); pocustomfield put('fieldtype', 'select'); pocustomfield put('scriptid', 'custbody customlist'); pocustomfield put('valuelookup', new map\<string, object>{'internalid'=>'2'}); pocustomfieldlist add(pocustomfield); // adding the purchase order custom fields nspurchaseorder put('customfieldlist', new map\<string, object>{'customfield'=>pocustomfieldlist}); // initializing the purchase 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('rate', '999'); // initializing 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); // adding the purchase order line item custom fields lineitem put('customfieldlist', new map\<string, object>{'customfield'=>licustomfieldlist}); lineitemlist add(lineitem); // adding the line items to purchase order map\<string, object> polineitemlist = new map\<string, object>(); polineitemlist put('item', lineitemlist); nspurchaseorder put('itemlist', polineitemlist); // initializing the requestjson data to be passed map\<string, object> requestjsonmap = new map\<string, object>(); requestjsonmap put('purchaseorders', new list\<object>{nspurchaseorder}); string reqjson = json serialize(requestjsonmap); map\<string, object> reqobj = new map\<string, object>(); reqobj put('version', '1 0'); reqobj put('action', 'createpurchaseorder'); reqobj put('requestjson', reqjson); // placing a request to breadwinner global api map\<string, object> resp = breadwinner ns breadwinnernetsuiteapi call(reqobj); system debug(resp); response { action=createpurchaseorder, timestamp=1606481122212, validrequest=true, version=1 0, responsejson={ "status" "200", "errors" \[], "purchaseorders" \[ { "tranid" "360", "trandate" 1599417000, "trackingnumbers" null, "total" 1178 82, "terms" null, "taxtotal" 179 82, "subtotal" 999 0, "subsidiary" { "type" null, "name" "parent company", "internalid" "1", "externalid" null }, "status" "pending receipt", "source" "web services", "shipto" { "type" null, "name" "21 atherton grocery", "internalid" "362", "externalid" null }, "shippingaddress" { "zip" "94567", "state" "ca", "internalid" null, "country" " unitedstates", "city" "pope valley", "attention" null, "addrphone" null, "addressee" null, "addr3" null, "addr2" "palo alto", "addr1" null }, "shipmethod" null, "shipdate" 1606415400, "salesforceid" "a0o2w000001rix8eaa", "otherrefnum" "4343399", "nullfieldlist" null, "memo" "po 12", "location" null, "lastmodifieddate" 1606481119, "itemlist" { "replaceall" null, "item" \[ { "unitsdisplay" null, "taxrate1" "18 0", "taxcode" { "type" null, "name" "vat in\ gst 18", "internalid" "36", "externalid" null }, "tax1amt" 179 82, "shipmethod" null, "shipgroup" null, "serialnumbers" null, "revrecstartdate" null, "revrecschedule" null, "revrecenddate" null, "rate" "999 00", "quantityremaining" null, "quantityreceived" 0 0, "quantitybilled" 0 0, "quantity" 1 0, "price" 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" 1178 82, "expectedreceiptdate" 1599417000, "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" "true", "scriptid" "custcol checkbox", "internalid" "443", "fieldtype" null } ] }, "createpo" null, "costestimatetype" null, "costestimate" null, "classification" null, "amount" 999 0 } ] }, "internalid" "54653", "fax" null, "externalid" null, "exchangerate" 1 0, "entity" { "type" null, "name" "rm textiles", "internalid" "30440", "externalid" null }, "employee" null, "email" null, "duedate" 1609353000, "department" { "type" null, "name" "sales", "internalid" "2", "externalid" null }, "customform" { "type" null, "name" "custom drop ship purchase order 6", "internalid" "119", "externalid" null }, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "false", "scriptid" "custbody34", "internalid" "558", "fieldtype" null }, { "valuelookup" { "type" null, "name" "b", "internalid" "2", "externalid" null }, "value" null, "scriptid" "custbody customlist", "internalid" "458", "fieldtype" null } ] }, "currencyrecord" null, "currencyname" "inr", "createdfrom" null, "createddate" 1606481118, "classification" { "type" null, "name" "corporate sales", "internalid" "5", "externalid" null }, "billingaddress" null } ] } }