Global API
Requests

Edit Transaction Item

3min
you can edit transaction items, also known as line items using the respective transaction update actions there will be scenarios when you only need to update line items instead of the entire transaction action values for different transactions will be ("update" + transaction name) ex to update sales order line items, we need to use the "updatesalesorder" action supported transactions sales transactions estimate, salesorder, cashsale, invoice, creditmemo, cashrefund, rma purchase transactions bills, purchase orders update sales order line items when updating transaction line items, set "replaceall" to false to prevent deleting existing line items also, to update existing lines, include the "line" value of the line item getting "line" value for existing line items use the key "line" to update a specific line item of the transaction and it takes the line item number as the key to achieve it and the line number of the line item can be found under the "additional information" section of the respective line item in the salesforce and if the requirement is only to add new line items, then no need to specify the "line" example the following is an example of editing line item/s of a transaction this example demonstrates editing the line items of the sales order and is also generically used to edit the line items of other transactions by modifying action values request // create a map to store all the data of a sales order map\<string, object> nssalesorder = new map\<string, object>(); nssalesorder put('internalid', '83943'); // internal id of the transaction whose line items need to be updated // initialize 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 test'); lineitem put('item', new map\<string, object>{'internalid'=>'239'}); lineitem put('line', 1); // use this to update the existing line items lineitem put('amount', 10); lineitem put('quantity', 2); lineitem put('grossamt', 220); lineitem put('tax1amt', 210); lineitem put('taxrate1', 1); lineitem put('revrecenddate', datetime newinstance(2021, 09, 07) gettime()/1000); lineitem put('revrecstartdate', datetime newinstance(2021, 09, 07) gettime()/1000); // 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', 'custbody checkbox'); licustomfield put('value', 'true'); licustomfieldlist add(licustomfield); // adding the sales order line item custom fields lineitem put('customfieldlist',new map\<string,object>{'customfield'=>licustomfieldlist}); lineitemlist add(lineitem); // addg the line items to sales order map\<string, object> solineitemlist = new map\<string, object>(); solineitemlist put('item',lineitemlist); solineitemlist put('replaceall', false); //false means it will append to existing lines 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', 'updatesalesorder'); //look table above for more action keys 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 = updatesalesorder, timestamp = 1621491360689, validrequest = true, version = 1 0, responsejson = { "status" "200", "errors" \[], "salesorders" \[ { "tranid" "1", "trandate" 1630953000, "total" 199 8, "taxtotal" 1 98, "subtotal" 217 82, "subsidiary" { "type" null, "name" "parent company", "internalid" "1", "externalid" null }, "status" "pending approval", "shippingcost" null, "shippingaddress" { "zip" "94567", "state" "ca", "internalid" null, "country" " unitedstates", "city" "pope valley", "attention" null, "addrphone" null, "addressee" "atherton grocery", "addr3" null, "addr2" "palo alto", "addr1" null }, "shipaddresslist" { "type" null, "name" "unnamed address", "internalid" "212", "externalid" null }, "salesrep" null, "salesforceid" "a0n5y00000xladruat", "otherrefnum" "4343390", "nullfieldlist" null, "memo" "order 30", "location" null, "lastmodifieddate" 1621491357, "itemlist" { "replaceall" null, "item" \[ { "unitsdisplay" null, "taxrate1" "1 0", "taxcode" { "type" null, "name" "vat in\ undef in", "internalid" "5", "externalid" null }, "tax1amt" 2 18, "shipmethod" null, "shipgroup" null, "serialnumbers" null, "revrecstartdate" null, "revrecschedule" null, "revrecenddate" null, "rate" "100 00", "quantityremaining" null, "quantityreceived" null, "quantitybilled" 0, "quantity" 2, "price" { "type" null, "name" "base price", "internalid" "1", "externalid" null }, "ponum" null, "orderline" null, "onhand" null, "location" null, "line" 38, "jobname" null, "itemreceive" null, "itemname" null, "itemisfulfilled" null, "item" { "type" null, "name" "bow", "internalid" "239", "externalid" null }, "grossamt" 220, "expectedreceiptdate" null, "description" "a weapon for shooting arrows test", "department" null, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "1", "scriptid" "custcol gh line no", "internalid" "175", "fieldtype" null } ] }, "createpo" " dropshipment", "costestimatetype" null, "costestimate" null, "classification" null, "amount" 217 82 } ] }, "internalid" "83943", "handlingcost" null, "externalid" "1", "exchangerate" 1, "entity" { "type" null, "name" "21 atherton grocery", "internalid" "362", "externalid" null }, "discounttotal" 20, "discountrate" " 20 00", "discountitem" { "type" null, "name" "partner discount", "internalid" " 6", "externalid" null }, "department" { "type" null, "name" "pr department", "internalid" "1", "externalid" null }, "customform" { "type" null, "name" "custom sales order 2", "internalid" "121", "externalid" null }, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" " ", "scriptid" "custbody breadwinner pc internal id", "internalid" "299", "fieldtype" null }, { "valuelookup" null, "value" "false", "scriptid" "custbody23", "internalid" "271", "fieldtype" null }, { "valuelookup" null, "value" "2021 05 19 23 15 57", "scriptid" "custbodylastmodifieddate", "internalid" "298", "fieldtype" null } ] }, "currencyrecord" null, "currencyname" "inr", "createdfrom" null, "createddate" 1620386017, "classification" { "type" null, "name" "individual partner class", "internalid" "2", "externalid" null }, "billingaddress" { "zip" "94567", "state" "ca", "internalid" null, "country" " unitedstates", "city" "pope valley", "attention" null, "addrphone" null, "addressee" "atherton grocery", "addr3" null, "addr2" "palo alto", "addr1" null }, "billaddresslist" { "type" null, "name" "unnamed address", "internalid" "212", "externalid" null } } ] } }