Global API
...
Requests
Purchase Order
Update
1min
the following is an example of updating a purchase order where we are changing some of the fields (see purchase order docid 5hsxrnfvysvm86eismioi for all available fields) the netsuite purchase order id (internalid) is required to update a purchase order note you can only update one record at a time the response returns the complete purchase order information but we have shortened the response in our example for ease of reading request // create a map to store all the data of a purchase order map\<string, object> nspurchaseorder = new map\<string, object>(); 	nspurchaseorder put('internalid', '120761'); nspurchaseorder put('classification', new map\<string, object>{'internalid'=>'9'}); nspurchaseorder put('currencyrecord', new map\<string, object>{'internalid'=>'2'}); nspurchaseorder put('department', new map\<string, object>{'internalid'=>'11'}); nspurchaseorder put('entity', new map\<string, object>{'internalid'=>'108018'}); nspurchaseorder put('memo', 'po 30'); nspurchaseorder put('otherrefnum', '4343399'); nspurchaseorder put('trandate', datetime newinstance(2023, 04, 28) 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'=>'3'}); 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'=>'8823'}); 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', 'false'); 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', 'updatepurchaseorder'); 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=updatepurchaseorder, timestamp=1682676021859, validrequest=true, version=1 0, responsejson={ "status" "200", "errors" \[], "purchaseorders" \[ { "tranid" "14669", "trandate" 1682650800, "trackingnumbers" null, "total" 999 0, "terms" null, "taxtotal" 0 0, "subtotal" 999 0, "subsidiary" { "type" null, "name" "parent company", "internalid" "1", "externalid" null }, "status" "pending receipt", "source" "web services", "shipto" null, "shippingaddress" null, "shipmethod" null, "shipdate" null, "salesforceid" "a0v1e000003bajteaa", "otherrefnum" "4343399", "nullfieldlist" null, "memo" "po 30", "location" null, "lastmodifieddate" 1682676018, "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" 0 0, "quantitypicked" null, "quantitypacked" null, "quantityonhand" null, "quantityfulfilled" null, "quantitycommitted" null, "quantitybilled" 0 0, "quantitybackordered" null, "quantityavailable" null, "quantity" 1 0, "price" null, "ponum" null, "percentcomplete" null, "orderline" null, "onhand" null, "location" null, "line" 4, "jobname" null, "itemreceive" null, "itemname" null, "itemisfulfilled" null, "item" { "type" null, "name" "blue jeans", "internalid" "8823", "externalid" null }, "isclosed" false, "grossamt" 999 0, "expectedreceiptdate" 1682650800, "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" "false", "scriptid" "custcol checkbox", "internalid" "443", "fieldtype" null }, { "valuelookup" null, "value" "error field 'custcol7' not found", "scriptid" "custcol11", "internalid" "656", "fieldtype" null } ] }, "createpo" null, "costestimatetype" null, "costestimate" null, "classification" null, "billingschedule" null, "amount" 999 0 } ] }, "internalid" "120761", "fax" null, "externalid" null, "expenselist" null, "exchangerate" 23 0, "entity" { "type" null, "name" "edge communications 1", "internalid" "108018", "externalid" null }, "employee" null, "email" null, "duedate" null, "department" { "type" null, "name" "space exploratory", "internalid" "11", "externalid" null }, "customform" { "type" null, "name" "standard purchase order", "internalid" "98", "externalid" null }, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "false", "scriptid" "custbody34", "internalid" "558", "fieldtype" null }, { "valuelookup" null, "value" " ", "scriptid" "custbody breadwinner pc internal id", "internalid" "588", "fieldtype" null }, { "valuelookup" { "type" null, "name" "c", "internalid" "3", "externalid" null }, "value" null, "scriptid" "custbody customlist", "internalid" "458", "fieldtype" null }, { "valuelookup" null, "value" "false", "scriptid" "custbody checkbox", "internalid" "272", "fieldtype" null }, { "valuelookup" null, "value" "false", "scriptid" "custbody enableimport", "internalid" "691", "fieldtype" null } ] }, "currencyrecord" { "type" null, "name" "us dollars", "internalid" "2", "externalid" null }, "currencyname" "us dollars", "createdfrom" null, "createddate" 1681902033, "classification" { "type" null, "name" "rocket science", "internalid" "9", "externalid" null }, "billingaddress" { "zip" null, "state" "tx", "internalid" null, "country" " india", "city" "austin", "attention" null, "addrphone" null, "addressee" "edge communications 1", "addr3" null, "addr2" null, "addr1" "312 constitution place austin, tx 78767 usa" } } ] } }