---
title: Update
slug: netsuite/ApM1-update
description: Learn how to update an invoice in NetSuite with this comprehensive example. Discover how to modify fields like invoice classification, department, memo, and reference numbers effortlessly. This document also showcases adding custom fields and line items t
docTags: 
createdAt: 2021-12-14T12:51:12.000Z
---

The following is an example of update Invoice where we are changing some of the fields. (See [﻿](https://app.archbee.io/docs/-LIHUUnv_7XNQrtzHsKkC/fgC9EQDMRKFQ6ct2cri5h)﻿[Invoice](docId\:XSrEr45ur9LxkfaHMkBrH) for all available fields).  The NetSuite Invoice Id (internalId) is required to update the Invoice.

:::hint{type="info"}
Note: You can only update one record at a time.&#x20;
:::

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


:::CodeblockTabs
Request

```apex
//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);
```

Response

```json
{
   action=updateInvoice,
   timestamp=1639492143080,
   validRequest=true,
   version=1.0,	
   responseJSON={
      "errors":[],
      "status":"200",	
      "invoices":[
         {
            "undepFunds":null,
            "tranId":"INV432",
            "tranDate":1601956800,
            "total":48.0,
            "terms":null,
            "taxTotal":0.0,
            "subTotal":48.0,
            "subsidiary":{
               "type":null,
               "name":"Parent Company",
               "internalId":"1",
               "externalId":null
            },
            "status":"Pending Approval",
            "shippingCost":null,
            "shippingAddress":null,
            "salesRep":{
               "type":null,
               "name":"Navaneeth.D",
               "internalId":"4",
               "externalId":null
            },
            "salesforceID":"a0B0l00000AvFE1EAN",
            "otherRefNum":"4343400",
            "nullFieldList":null,
            "memo":"Invoice 215",
            "location":{
               "type":null,
               "name":"test : Atlanta west",
               "internalId":"1",
               "externalId":null
            },
            "lastModifiedDate":1639492139,
            "itemList":{
               "replaceAll":null,
               "item":[
                  {
                     "unitsDisplay":null,
                     "taxRate1":"0.0",
                     "taxCode":{
                        "type":null,
                        "name":"VAT_IN:UNDEF-IN",
                        "internalId":"5",
                        "externalId":null
                     },
                     "tax1Amt":0.0,
                     "shipMethod":null,
                     "shipGroup":null,
                     "serialNumbers":null,
                     "revRecStartDate":null,
                     "revRecSchedule":null,
                     "revRecEndDate":null,
                     "rate":"2.00",
                     "quantityRemaining":null,
                     "quantityReceived":null,
                     "quantityBilled":null,
                     "quantity":6.0,
                     "price":{
                        "type":null,
                        "name":"Base Price",
                        "internalId":"1",
                        "externalId":null
                     },
                     "poNum":null,
                     "orderLine":null,
                     "onHand":null,
                     "location":null,
                     "line":1,
                     "jobName":null,
                     "itemReceive":null,
                     "itemName":null,
                     "itemIsFulfilled":null,
                     "item":{
                        "type":null,
                        "name":"Bow",
                        "internalId":"239",
                        "externalId":null
                     },
                     "grossAmt":12.0,
                     "expectedReceiptDate":null,
                     "description":" For shooting arrows",
                     "department":null,
                     "customFieldList":{
                        "customField":[
                           {
                              "valueLookup":null,
                              "value":"1",
                              "scriptId":"custcol_gh_line_no",
                              "internalId":"175",
                              "fieldType":null
                           },
                           {
                              "valueLookup":null,
                              "value":"false",
                              "scriptId":"custcol_checkbox",
                              "internalId":"443",
                              "fieldType":null
                           }
                        ]
                     },
                     "createPo":null,
                     "costEstimateType":null,
                     "costEstimate":null,
                     "classification":null,
                     "amount":12.0
                  },
                  {
                     "unitsDisplay":null,
                     "taxRate1":"0.0",
                     "taxCode":{
                        "type":null,
                        "name":"VAT_IN:UNDEF-IN",
                        "internalId":"5",
                        "externalId":null
                     },
                     "tax1Amt":0.0,
                     "shipMethod":null,
                     "shipGroup":null,
                     "serialNumbers":null,
                     "revRecStartDate":null,
                     "revRecSchedule":null,
                     "revRecEndDate":null,
                     "rate":"9.00",
                     "quantityRemaining":null,
                     "quantityReceived":null,
                     "quantityBilled":null,
                     "quantity":4.0,
                     "price":{
                        "type":null,
                        "name":"Alternate Price 1",
                        "internalId":"2",
                        "externalId":null
                     },
                     "poNum":null,
                     "orderLine":null,
                     "onHand":null,
                     "location":null,
                     "line":3,
                     "jobName":null,
                     "itemReceive":null,
                     "itemName":null,
                     "itemIsFulfilled":null,
                     "item":{
                        "type":null,
                        "name":"Apple",
                        "internalId":"444",
                        "externalId":null
                     },
                     "grossAmt":36.0,
                     "expectedReceiptDate":null,
                     "description":"sales",
                     "department":null,
                     "customFieldList":{
                        "customField":[
                           {
                              "valueLookup":null,
                              "value":"2",
                              "scriptId":"custcol_gh_line_no",
                              "internalId":"175",
                              "fieldType":null
                           },
                           {
                              "valueLookup":null,
                              "value":"false",
                              "scriptId":"custcol_checkbox",
                              "internalId":"443",
                              "fieldType":null
                           }
                        ]
                     },
                     "createPo":null,
                     "costEstimateType":null,
                     "costEstimate":null,
                     "classification":null,
                     "amount":36.0
                  }
               ]
            },
            "internalId":"91404",
            "handlingCost":null,
            "externalId":null,
            "exchangeRate":1.0,
            "entity":{
               "type":null,
               "name":"21 Atherton Grocery",
               "internalId":"362",
               "externalId":null
            },
            "dueDate":1601956800,
            "discountTotal":0.0,
            "discountRate":null,
            "discountItem":null,
            "department":{
               "type":null,
               "name":"PR Department",
               "internalId":"1",
               "externalId":null
            },
            "customForm":{
               "type":null,
               "name":"Custom Product Invoice",
               "internalId":"104",
               "externalId":null
            },
            "customFieldList":{
               "customField":[
                  {
                     "valueLookup":{
                        "type":null,
                        "name":"B",
                        "internalId":"2",
                        "externalId":null
                     },
                     "value":null,
                     "scriptId":"custbody_customlist",
                     "internalId":"458",
                     "fieldType":null
                  },
                  {
                     "valueLookup":null,
                     "value":"true",
                     "scriptId":"custbody_checkbox",
                     "internalId":"272",
                     "fieldType":null
                  }
               ]
            },
            "currencyRecord":{
               "type":null,
               "name":"US Dollars",
               "internalId":"2",
               "externalId":null
            },
            "currencyName":"US Dollars",
            "createdFrom":null,
            "createdDate":1639488959,
            "classification":{
               "type":null,
               "name":"Individual Partner Class",
               "internalId":"2",
               "externalId":null
            },
            "billingAddress":{
               "zip":null,
               "state":"TamilNadu",
               "internalId":null,
               "country":"_india",
               "city":"Madurai",
               "attention":null,
               "addrPhone":null,
               "addressee":null,
               "addr3":null,
               "addr2":"bvr Street",
               "addr1":"Dno 32-123-23"
            },
            "account":{
               "type":null,
               "name":"Accounts Receivable",
               "internalId":"122",
               "externalId":null
            }
         }
      ]
   }
}
```
:::

