Global API
...
Requests
Vendor Bill
Update
1min
The following is an example of an update Vendor Bill where we are changing some of the fields (see Vendor Bill for all available fields). The NetSuite Vendor Bill Id (internalId) is required to update the Vendor Bill.
Note: You can only update one record at a time.
The response returns the complete Vendor Bill information, but we have shortened the response in our example for ease of reading.
Request
Response
1// Create a Map to store all the data of a VendorBill
2 Map<String, Object> nsVendorBill = new Map<String, Object>();
3 nsVendorBill.put('internalId', '113553');
4 nsVendorBill.put('classification', new Map<String, Object>{'internalId'=>'2'});
5 nsVendorBill.put('currencyRecord', new Map<String, Object>{'internalId'=>'1'});
6
7 nsVendorBill.put('entity', new Map<String, Object>{'internalId'=>'362'});
8 nsVendorBill.put('memo', 'Bill 30');
9 nsVendorBill.put('otherRefNum', '4343390');
10 nsVendorBill.put('tranDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);
11
12// Initializing the VendorBill Custom Fields
13 List<Object> billCustomFieldList = new List<Object>();
14 Map<String,Object> billCustomField = new Map<String,Object>();
15 billCustomField.put('fieldType', 'select');
16 billCustomField.put('scriptId', 'custbody_customlist');
17 billCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'2'});
18 billCustomFieldList.add(billCustomField);
19
20// Adding the VendorBill Custom Fields
21 nsVendorBill.put('customFieldList', new Map<String,Object>{'customField'=>billCustomFieldList});
22
23// Initializing the VendorBill Line Items
24 List<Object> lineItemList = new List<Object>();
25 Map<String, Object> lineItem = new Map<String, Object>();
26 lineItem.put('description', 'A weapon for shooting arrows test');
27 lineItem.put('item', new Map<String, Object>{'internalId'=>'239'});
28 lineItem.put('replaceAll', false);
29 lineItem.put('amount', 10);
30 lineItem.put('quantity', 2);
31 lineItem.put('grossAmt', 220);
32 lineItem.put('tax1Amt', 210);
33 lineItem.put('revRecEndDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);
34 lineItem.put('revRecStartDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);
35
36// Initializing the Line Item custom fields
37 List<Object> liCustomFieldList = new List<Object>();
38 Map<String, Object> liCustomField = new Map<String, Object>();
39 liCustomField.put('fieldType', 'boolean');
40 liCustomField.put('scriptId', 'custbody_checkbox');
41 liCustomField.put('value', 'true');
42 liCustomFieldList.add(liCustomField);
43
44// Adding the VendorBill Line Item Custom Fields
45 lineItem.put('customFieldList',new Map<String,Object>{'customField'=>liCustomFieldList});
46 lineItemList.add(lineItem);
47
48// Adding the Line Items to VendorBill
49 Map<String, Object> billLineitemList = new Map<String, Object>();
50 billLineitemList.put('item',lineItemList);
51 nsVendorBill.put('itemList',billLineitemList);
52
53// Initializing the RequestJSON Data to be passed.
54 Map<String, Object> requestJSONMap = new Map<String, Object>();
55 requestJSONMap.put('vendorBills', new List<Object>{nsVendorBill});
56 String reqJSON = JSON.serialize(requestJSONMap);
57
58 Map<String, Object> reqObj = new Map<String, Object>();
59 reqObj.put('version', '1.0');
60 reqObj.put('action', 'updateVendorBill');
61 reqObj.put('requestJSON', reqJSON);
62
63// Placing a request to Breadwinner Global API
64 Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
65 System.debug(resp);


Updated 14 Jun 2024
Did this page help you?