Update
1 min
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.
// Create a Map to store all the data of a VendorBill
Map<String, Object> nsVendorBill = new Map<String, Object>();
nsVendorBill.put('internalId', '113553');
nsVendorBill.put('classification', new Map<String, Object>{'internalId'=>'2'});
nsVendorBill.put('currencyRecord', new Map<String, Object>{'internalId'=>'1'});
nsVendorBill.put('entity', new Map<String, Object>{'internalId'=>'362'});
nsVendorBill.put('memo', 'Bill 30');
nsVendorBill.put('otherRefNum', '4343390');
nsVendorBill.put('tranDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);
// Initializing the VendorBill Custom Fields
List<Object> billCustomFieldList = new List<Object>();
Map<String,Object> billCustomField = new Map<String,Object>();
billCustomField.put('fieldType', 'select');
billCustomField.put('scriptId', 'custbody_customlist');
billCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'2'});
billCustomFieldList.add(billCustomField);
// Adding the VendorBill Custom Fields
nsVendorBill.put('customFieldList', new Map<String,Object>{'customField'=>billCustomFieldList});
// Initializing the VendorBill 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('replaceAll', false);
lineItem.put('amount', 10);
lineItem.put('quantity', 2);
lineItem.put('grossAmt', 220);
lineItem.put('tax1Amt', 210);
lineItem.put('revRecEndDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);
lineItem.put('revRecStartDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);
// Initializing 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 VendorBill Line Item Custom Fields
lineItem.put('customFieldList',new Map<String,Object>{'customField'=>liCustomFieldList});
lineItemList.add(lineItem);
// Adding the Line Items to VendorBill
Map<String, Object> billLineitemList = new Map<String, Object>();
billLineitemList.put('item',lineItemList);
nsVendorBill.put('itemList',billLineitemList);
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('vendorBills', new List<Object>{nsVendorBill});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'updateVendorBill');
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);