Global API
...
Request
Purchase Order
Update
1min
to update a po in xero, make sure you set the field "purchaseorderid" with the unique reference value (id generated by xero for the po) request // create a map to store all the data of a purchase order list\<object> purchaseorderlist = new list\<object>(); map\<string, object> purchaseordermap = new map\<string, object>(); purchaseordermap put('datestring', '2021 11 11t00 00 00'); purchaseordermap put('deliverydate', '2021 12 06t00 00 00'); purchaseordermap put('status', 'authorised'); purchaseordermap put('purchaseorderid', '2fef007e 1979 4634 9bb7 87c4559a0038'); // initializing the contact map\<string, object> contactmap = new map\<string, object>(); contactmap put('contactid', 'c84ebb15 0a8d 4145 933f 203e68d014a0'); purchaseordermap put('contact', contactmap); // initializing the purchase order line items list\<object> lineitemlist = new list\<object>(); map\<string, object> lineitemmap = new map\<string, object>(); lineitemmap put('description', 'line item description updated'); lineitemmap put('unitamount', 100); lineitemmap put('quantity', 10); 	 lineitemmap put('accountcode', '310'); lineitemmap put('lineitemid', 'fd9bd48c 9f10 44de aee4 c6185b2868c3'); lineitemlist add(lineitemmap); // adding the line items to purchase order purchaseordermap put('lineitems', lineitemlist); purchaseorderlist add(purchaseordermap); // initializing the requestjson data to be passed map\<string, object> reqjsonmap = new map\<string, object>(); reqjsonmap put('purchaseorders', purchaseorderlist); string reqjson = json serialize(reqjsonmap); map\<string, object> finalreqmap = new map\<string, object>(); finalreqmap put('version', '1 0'); finalreqmap put('action', 'updatepurchaseorder'); finalreqmap put('requestjson', reqjson); finalreqmap put('skipdml', false); //required, if xero multi org is enabled in breadwinner finalreqmap put('xeroorgid', '!aa00tm'); system debug('request ' + finalreqmap); // placing a request to breadwinner global api map\<string, object> respmap = bread winner breadwinnerxeroapi call(finalreqmap); system debug('response ' + respmap); response { action=updatepurchaseorder, responsejson={ "statuscode" 200, "purchaseorders" \[ { "updateddateutc"\ null, "type" "purchaseorder", "totaltax" 0 00, "totaldiscount" 0 00, "total" 1000 00, "telephone" "", "subtotal" 1000 00, "status" "authorised", "senttocontact"\ false, "salesforcerecordid" "a0k7f00001eft7nuac", "reference"\ null, "purchaseordernumber" "po 0001", "purchaseorderid" "2fef007e 1979 4634 9bb7 87c4559a0038", "payments"\ null, "lineitems" \[ { "unitamount" 100 0000, "tracking" \[ ], "taxtype" "input", "taxamount" 0 00, "quantity" 10 0000, "lineitemid" "fd9bd48c 9f10 44de aee4 c6185b2868c3", "lineamount" 1000 00, "itemcode"\ null, "discountrate"\ null, "description" "line item description updated", "accountcode" "310" } ], "lineamounttypes" "exclusive", "isdiscounted"\ false, "invoicenumber"\ null, "invoiceid"\ null, "haserrors"\ false, "duedatestring"\ null, "duedate"\ null, "deliveryinstructions" "", "deliverydatestring" "2021 12 06t00 00 00", "deliverydate" "2021 12 06", "deliveryaddress" "", "datevariable" "/date(1636588800000+0000)/", "datestring" "2021 11 11t00 00 00", "currencyrate" 1 0000000000, "currencycode" "inr", "creditnotes"\ null, "contact" { "name" "test contact 2", "contactstatus" "active", "contactid" "c84ebb15 0a8d 4145 933f 203e68d014a0" }, "brandingthemeid"\ null, "attentionto" "", "amountpaid"\ null, "amountdue"\ null, "amountcredited" 0 00 } ], "errors" \[ ] }, timestamp=1636643453213, validrequest=true, version=1 0 }