website logo
Product Overview
NetSuite
Payments
QuickBooks
Xero
Navigate through spaces
⌘K
General Concepts
What is Breadwinner
Getting Started
App Installation
Initial Configuration
Person Accounts
Company Matching
Product Matching
NetSuite Items and Item Groups
Download PDF button
Weekly Sync Timeframe
Security and Permissions
NetSuite Permissions
Custom Guided Wizard
Quick Create Sales Order
Button URL Structure
NetSuite Company Creation
Button URL Generator
Support
Custom Fields
Custom Objects
Global API
Quick Start Guide
API Overview
Requests
Response
Apex Generator
Code Examples
Advanced Topics
Formula Fields
NetSuite Discounts
NetSuite Payment Terms
Memorized Transactions
Sync Data Filtering
Technical Resources
Deploy Plan
Requirements
ERD / Object Structure
Getting Help
Version History
Direct Installation Link
Docs powered by
Archbee
Global API
...
Requests
Invoice

Update

2min

The following is an example of update Invoice where we are changing some of the fields. (See Invoice for all available fields). The NetSuite Invoice Id (internalId) is required to update the Invoice.

Note: You can only update one record at a time.

The response returns the complete Invoice information, but we have shortened the response in our example for ease of reading.

Request
Response
|
//Create a Map to store all the data of a Invoice
Map<String, Object> nsInvoice = new Map<String, Object>();
	nsInvoice.put('internalId', '91404');
    nsInvoice.put('classification', new Map<String, Object>{'internalId'=>'2'});
    nsInvoice.put('department', new Map<String, Object>{'internalId'=>'1'});
	nsInvoice.put('memo', 'Invoice 215');
    nsInvoice.put('otherRefNum', '4343400');
    nsInvoice.put('tranDate', DateTime.newInstance(2020, 10, 07).getTime()/1000);
//  Initializing the Invoice Custom Fields
    List<Object> invCustomFieldList = new List<Object>();
    Map<String,Object> invCustomField = new Map<String,Object>();
        invCustomField.put('fieldType', 'boolean');
        invCustomField.put('scriptId', 'custbody_checkbox');
        invCustomField.put('value', 'true');
        invCustomFieldList.add(invCustomField);

//  Adding the Invoice Custom Fields
    nsInvoice.put('customFieldList', new Map<String,Object>{'customField'=>invCustomFieldList});

    //  Initializing the Invoice Line Items
    List<Object> lineItemList = new List<Object>();
    Map<String, Object> lineItem = new Map<String, Object>();
        lineItem.put('description', ' For shooting arrows');
        lineItem.put('line', 1); // updates the existing line item with line number as 1.
        lineItem.put('quantity', 6);
		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', 'custcol_checkbox');
            liCustomField.put('value', 'false');
            liCustomFieldList.add(liCustomField);

//  Adding the Invoice Line Item Custom Fields
        lineItem.put('customFieldList', new Map<String, Object>{'customField'=>liCustomFieldList});
        lineItemList.add(lineItem);
//  Adding Another Line Item
	lineItem = new Map<String, Object>();
        lineItem.put('item', new Map<String, Object>{'internalId'=>'444'});
        lineItem.put('quantity', 4);
        lineItem.put('price', new Map<String, Object>{'internalId'=>'2'});
        lineItemList.add(lineItem);

//  Adding the Line Items to Invoice
    Map<String, Object> invLineitemList = new Map<String, Object>();
        invLineitemList.put('item', lineItemList);
		invLineitemList.put('replaceAll', false);
    nsInvoice.put('itemList', invLineitemList);

//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
    requestJSONMap.put('invoices', new List<Object>{nsInvoice});
    String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'updateInvoice');
    reqObj.put('requestJSON', reqJSON);

//  Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);




Updated 26 Jul 2023
Did this page help you?
PREVIOUS
Create
NEXT
Delete
Docs powered by
Archbee
Docs powered by
Archbee