Global API
...
Request
Purchase Order
Create
1min
the following is an example of creating a purchase order where we are setting every possible field (see purchase order docid\ j53axk0qebupb8e wav9 for the available fields) the response will return the exact request data plus the new quickbooks purchaseorder id (id) note you can only create one record at a time request // create a map to store all the data of a purchase order map\<string, object> purchaseordermap = new map\<string, object>(); list\<object> lineitemlist = new list\<object>(); list\<object> purchaseorderlist = new list\<object>(); // assign value of opportunity to quickbook purchaseorder 	 purchaseordermap put('txndate','2024 04 26'); purchaseordermap put('duedate','2024 05 26'); purchaseordermap put('docnumber', '0001'); 	 purchaseordermap put('vendorref' , new map\<string, object>{'value' => '67' }); purchaseordermap put('privatenote' , 'create'); 	 map\<string, object> lineitemmap = new map\<string, object>(); 	 map\<string, object> saleslineitemdetailmap = new map\<string, object>(); lineitemmap put('detailtype','itembasedexpenselinedetail'); lineitemmap put('amount',1000); saleslineitemdetailmap put('itemref' , new map\<string, object>{'value' => '19' }); saleslineitemdetailmap put('qty','10'); saleslineitemdetailmap put('unitprice','100'); if(lineitemmap get('detailtype') == 'salesitemlinedetail'){ lineitemmap put('salesitemlinedetail',saleslineitemdetailmap); }else if(lineitemmap get('detailtype') == 'itembasedexpenselinedetail'){ lineitemmap put('itembasedexpenselinedetail',saleslineitemdetailmap); } lineitemlist add(lineitemmap); // adding the line items to quickbook purchaseorder purchaseordermap put('line',lineitemlist); purchaseorderlist add(purchaseordermap); 	 map\<string, object> reqjsonmap = new map\<string, object>(); reqjsonmap put('purchaseorder' , purchaseorderlist); string reqjson = json serialize(reqjsonmap); map\<string, object> finalreqmap = new map\<string, object>(); map\<string,object> reqoptions = new map\<string,object>(); finalreqmap put('options' , reqoptions); finalreqmap put('version' , '1 0'); finalreqmap put('action' , 'createpurchaseorder'); finalreqmap put('requestjson' , reqjson); // required, if quickbooks multi org is enabled in breadwinner finalreqmap put('qborgid' , '4620816365285051610'); finalreqmap put('skipdml' , false); system debug('request ' + finalreqmap); 	 map\<string, object> respmap = breadwinner qbo breadwinnerqbapi call(finalreqmap); system debug('response ' + respmap); response { action=createpurchaseorder, timestamp=1716959203946, validrequest=true, version=1 0, responsejson={ "statuscode" 200, "purchaseorder" \[ { "vendorref" { "value" "67", "name" "3 39" }, "txndate" "2024 04 26", "totalamt" 1000 00, "synctoken" "0", "sparse"\ false, "sfrecordid" "a01ig000000pdskias", "privatenote" "create", "postatus" "open", "metadata" { "lastupdatedtime" "2024 05 28t22 06 42 07 00", "createtime" "2024 05 28t22 06 42 07 00" }, "line" \[ { "linenum" 1, "itembasedexpenselinedetail" { "unitprice" 100, "taxcoderef" { "value" "non" }, "qty" 10, "itemref" { "value" "19", "name" "genwatt diesel 1000kw" }, "billablestatus" "notbillable" }, "id" "1", "detailtype" "itembasedexpenselinedetail", "amount" 1000 00 } ], "id" "228", "docnumber" "0001", "customfield" \[ { "type" "stringtype", "name" "1", "definitionid" "1" }, { "type" "stringtype", "name" "2", "definitionid" "2" }, { "type" "stringtype", "name" "3", "definitionid" "3" } ], "currencyref" { "value" "usd", "name" "united states dollar" }, "apaccountref" { "value" "33", "name" "accounts payable (a/p)" } } ] } }