---
title: Update
slug: netsuite/h3hS-update
description: Learn how to update a NetSuite Cash Sale using Apex code with this informative document. The provided code snippet showcases the creation of a Map object that stores essential data for the Cash Sale, including internalId, classification, department, memo,
docTags: 
createdAt: 2021-12-14T13:05:29.000Z
---

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

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

The response returns the complete Cash Sale information, but we have shortened the response in our example for ease of reading.&#x20;

:::CodeblockTabs
Request

```apex
//Create a Map to store all the data of a Cash Sale
Map<String, Object> nsCashSale = new Map<String, Object>();
	nsCashSale.put('internalId', '91704');
    nsCashSale.put('classification', new Map<String, Object>{'internalId'=>'2'});
    nsCashSale.put('department', new Map<String, Object>{'internalId'=>'1'});
	nsCashSale.put('memo', 'CashSale 215');
    nsCashSale.put('otherRefNum', '43434544');
//  Initializing the Cash Sale Custom Fields
    List<Object> csCustomFieldList = new List<Object>();
    Map<String,Object> csCustomField = new Map<String,Object>();
        csCustomField.put('fieldType', 'boolean');
        csCustomField.put('scriptId', 'custbody_checkbox');
        csCustomField.put('value', 'false');
        csCustomFieldList.add(csCustomField);

//  Adding the Cash Sale Custom Fields
    nsCashSale.put('customFieldList', new Map<String,Object>{'customField'=>csCustomFieldList});

    //  Initializing the Cash Sale 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', 15);
//  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', 'true');
            liCustomFieldList.add(liCustomField);

//  Adding the Cash Sale Line Item Custom Fields
        lineItem.put('customFieldList', new Map<String, Object>{'customField'=>liCustomFieldList});
        lineItemList.add(lineItem);
//  Adding the Line Items to Cash Sale
    Map<String, Object> csLineitemList = new Map<String, Object>();
        csLineitemList.put('item', lineItemList);
		csLineitemList.put('replaceAll', false);
    nsCashSale.put('itemList', csLineitemList);

//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
    requestJSONMap.put('cashSales', new List<Object>{nsCashSale});
    String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'updateCashSale');
    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=updateCashSale,
    timestamp=1639554954330,
    validRequest=true,
    version=1.0,
    responseJSON={
      "errors":[],
      "status":"200",  
      "CashSales":[
         {
            "undepFunds":true,
            "tranId":"13",
            "tranDate":1601956800,
            "total":30.0,
            "terms":null,
            "taxTotal":0.0,
            "subTotal":30.0,
            "subsidiary":{
               "type":null,
               "name":"Parent Company",
               "internalId":"1",
               "externalId":null
            },
            "status":"Not Deposited",
            "shippingCost":null,
            "shippingAddress":null,
            "salesRep":{
               "type":null,
               "name":"Navaneeth.D",
               "internalId":"4",
               "externalId":null
            },
            "salesforceID":"a0B0l00000AvFSgEAN",
            "otherRefNum":"43434544",
            "nullFieldList":null,
            "memo":"CashSale 215",
            "location":{
               "type":null,
               "name":"test : Atlanta west",
               "internalId":"1",
               "externalId":null
            },
            "lastModifiedDate":1639554948,
            "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":15.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":30.0,
                     "expectedReceiptDate":null,
                     "description":" For shooting arrows",
                     "department":null,
                     "customFieldList":{
                        "customField":[
                           {
                              "valueLookup":null,
                              "value":"true",
                              "scriptId":"custcol_checkbox",
                              "internalId":"443",
                              "fieldType":null
                           }
                        ]
                     },
                     "createPo":null,
                     "costEstimateType":null,
                     "costEstimate":null,
                     "classification":null,
                     "amount":30.0
                  }
               ]
            },
            "internalId":"91704",
            "handlingCost":null,
            "externalId":null,
            "exchangeRate":1.0,
            "entity":{
               "type":null,
               "name":"21 Atherton Grocery",
               "internalId":"362",
               "externalId":null
            },
            "dueDate":null,
            "discountTotal":0.0,
            "discountRate":null,
            "discountItem":null,
            "department":{
               "type":null,
               "name":"PR Department",
               "internalId":"1",
               "externalId":null
            },
            "customForm":null,
            "customFieldList":{
               "customField":[
                  {
                     "valueLookup":null,
                     "value":" - ",
                     "scriptId":"custbody_breadwinner_pc_internal_id",
                     "internalId":"588",
                     "fieldType":null
                  },
                  {
                     "valueLookup":null,
                     "value":"false",
                     "scriptId":"custbody_checkbox",
                     "internalId":"272",
                     "fieldType":null
                  }
               ]
            },
            "currencyRecord":{
               "type":null,
               "name":"US Dollars",
               "internalId":"2",
               "externalId":null
            },
            "currencyName":"US Dollars",
            "createdFrom":null,
            "createdDate":1639554102,
            "classification":{
               "type":null,
               "name":"Individual Partner Class",
               "internalId":"2",
               "externalId":null
            },
            "billingAddress":{
               "zip":"94567",
               "state":"CA",
               "internalId":null,
               "country":"_unitedStates",
               "city":"Pope Valley",
               "attention":null,
               "addrPhone":null,
               "addressee":null,
               "addr3":null,
               "addr2":"Palo Alto",
               "addr1":null
            },
            "account":null
         }
      ]
   }
}
```
:::





