Global API
...
Request
Purchase Order
Update
1min
The following is an example of update Purchase Order. The QuickBooks Purchase Order Id (id), Vendor Reference Id (VendorRef) and Sync Token (SyncToken) are required to update the Purchase Order (See Purchase Order for the available fields).
Note: You can only create one record at a time.
Request
Response
1// Create a Map to store all the data of a Purchase Order
2 Map<String, Object> purchaseOrderMap = new Map<String, Object>();
3 List<Object> lineItemList = new List<Object>();
4 List<Object> purchaseOrderList = new List<Object>();
5
6// Assign value of Opportunity to QuickBook PurchaseOrder
7 purchaseOrderMap.put('TxnDate','2024-04-26');
8 purchaseOrderMap.put('DueDate','2024-05-26');
9 purchaseOrderMap.put('Id','193');
10 purchaseOrderMap.put('SyncToken','0');
11 purchaseOrderMap.put('PurchaseOrderEmail' , new Map<String, Object>{'EmailAddress' =>'[email protected]'});
12 purchaseOrderMap.put('VendorRef' , new Map<String, Object>{'value' => '83' });
13 purchaseOrderMap.put('PrivateNote' , 'updated');
14
15// Assign value of OpportunityLineItem to QuickBook PurchaseOrder
16 Map<String, Object> lineItemMap = new Map<String, Object>();
17 Map<String, Object> salesLineItemDetailMap = new Map<String, Object>();
18 lineItemMap.put('Description','Updated');
19 lineItemMap.put('DetailType','ItemBasedExpenseLineDetail');
20 lineItemMap.put('Amount',100);
21 salesLineItemDetailMap.put('ItemRef' , new Map<String, Object>{'value' => '19' });
22 salesLineItemDetailMap.put('Qty','10');
23 salesLineItemDetailMap.put('UnitPrice','10');
24 if(lineItemMap.get('DetailType') == 'SalesItemLineDetail'){
25 lineItemMap.put('SalesItemLineDetail',salesLineItemDetailMap);
26 }else if(lineItemMap.get('DetailType') == 'ItemBasedExpenseLineDetail'){
27 lineItemMap.put('ItemBasedExpenseLineDetail',salesLineItemDetailMap);
28 }
29 lineItemList.add(lineItemMap);
30
31// Adding the Line Items to QuickBook PurchaseOrder
32 purchaseOrderMap.put('Line',lineItemList);
33 purchaseOrderList.add(purchaseOrderMap);
34 Map<String, Object> reqJSONMap = new Map<String, Object>();
35 reqJSONMap.put('PurchaseOrder' , purchaseOrderList);
36 String reqJSON = JSON.serialize(reqJSONMap);
37 Map<String, Object> finalReqMap = new Map<String, Object>();
38 Map<String,Object> reqOptions = new Map<String,Object>();
39 finalReqMap.put('options' , reqOptions);
40 finalReqMap.put('version' , '1.0');
41 finalReqMap.put('action' , 'updatePurchaseOrder');
42 finalReqMap.put('RequestJSON' , reqJSON);
43 // Required, if QuickBooks Multi-Org is enabled in Breadwinner.
44 finalReqMap.put('qbOrgId' , '4620816365285051610');
45 finalReqMap.put('skipDML' , false);
46 System.debug('Request ::: ' + finalReqMap);
47 Map<String, Object> respMap = breadwinner_qbo.BreadwinnerQBAPI.call(finalReqMap);
48 System.debug('Response ::: ' + respMap);