---
title: Update
slug: netsuite/o5kJ-update
description: Learn how to update a Cash Refund record in NetSuite using Apex code. This step-by-step guide includes creating a data map, adding custom fields and line items, and making a request to the Breadwinner Global API. Get the updated Cash Refund information ea
docTags: 
createdAt: 2023-04-25T05:39:22.000Z
---

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

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

The response returns the complete Cash Refund 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 Refund
Map<String, Object> nsCashRefund = new Map<String, Object>();
	nsCashRefund.put('internalId', '121357');
    nsCashRefund.put('classification', new Map<String, Object>{'internalId'=>'4'});
    nsCashRefund.put('department', new Map<String, Object>{'internalId'=>'1'});
	nsCashRefund.put('memo', 'CashRefund 215');
    nsCashRefund.put('otherRefNum', '43434544');
//  Initializing the Cash Refund Custom Fields
    List<Object> crCustomFieldList = new List<Object>();
    Map<String,Object> crCustomField = new Map<String,Object>();
        crCustomField.put('fieldType', 'boolean');
        crCustomField.put('scriptId', 'custbody_checkbox');
        crCustomField.put('value', 'false');
        crCustomFieldList.add(crCustomField);

//  Adding the Cash Refund Custom Fields
    nsCashRefund.put('customFieldList', new Map<String,Object>{'customField'=>crCustomFieldList});

    //  Initializing the Cash Refund 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);
		lineItem.put('Amount', 150);
//  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 Refund Line Item Custom Fields
        lineItem.put('customFieldList', new Map<String, Object>{'customField'=>liCustomFieldList});
        lineItemList.add(lineItem);
//  Adding the Line Items to Cash Refund
    Map<String, Object> crLineitemList = new Map<String, Object>();
        crLineitemList.put('item', lineItemList);
		crLineitemList.put('replaceAll', false);
    nsCashRefund.put('itemList', crLineitemList);

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

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'updateCashRefund');
    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=updateCashRefund,
  timestamp=1682500479120,
  validRequest=true,
  version=1.0,
  responseJSON={
    "errors": [],
    "status": "200",
    "CashRefunds": [
      {
        "tranId": "16",
        "tranDate": 1682478000,
        "total": 400.0,
        "taxTotal": 0.0,
        "subTotal": 400.0,
        "subsidiary": {
          "type": null,
          "name": "Parent Company",
          "internalId": "1",
          "externalId": null
        },
        "status": null,
        "shippingCost": 0.0,
        "salesRep": null,
        "salesforceID": "a061e000003Ux0KAAS",
        "refundCheck": false,
        "otherRefNum": "43434544",
        "memo": "CashRefund 215",
        "location": {
          "type": null,
          "name": "Hyderabad : Hi-Tech City",
          "internalId": "10",
          "externalId": null
        },
        "lastModifiedDate": 1682500474,
        "job": null,
        "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": null,
              "quantityRemaining": null,
              "quantityReceived": null,
              "quantityPicked": null,
              "quantityPacked": null,
              "quantityOnHand": null,
              "quantityFulfilled": null,
              "quantityCommitted": null,
              "quantityBilled": null,
              "quantityBackOrdered": null,
              "quantityAvailable": null,
              "quantity": 15.0,
              "price": {
                "type": null,
                "name": null,
                "internalId": "-1",
                "externalId": null
              },
              "poNum": null,
              "percentComplete": null,
              "orderLine": null,
              "onHand": null,
              "location": null,
              "line": 1,
              "jobName": null,
              "itemReceive": null,
              "itemName": null,
              "itemIsFulfilled": null,
              "item": {
                "type": null,
                "name": "Blue Jeans",
                "internalId": "8823",
                "externalId": null
              },
              "isClosed": null,
              "grossAmt": 400.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": "_lastPurchasePrice",
              "costEstimate": 0.0,
              "classification": null,
              "billingSchedule": null,
              "amount": 400.0
            }
          ]
        },
        "internalId": "121459",
        "handlingCost": 0.0,
        "externalId": null,
        "exchangeRate": 1.0,
        "entity": {
          "type": null,
          "name": "CUST1402AT Blue Origin",
          "internalId": "109118",
          "externalId": null
        },
        "discountTotal": 0.0,
        "discountRate": null,
        "discountItem": null,
        "department": {
          "type": null,
          "name": "test",
          "internalId": "3",
          "externalId": null
        },
        "customForm": {
          "type": null,
          "name": "Custom Cash Refund",
          "internalId": "128",
          "externalId": null
        },
        "customFieldList": {
          "customField": [
            {
              "valueLookup": null,
              "value": "400",
              "scriptId": "custbody42",
              "internalId": "869",
              "fieldType": null
            },
            {
              "valueLookup": null,
              "value": " - ",
              "scriptId": "custbody_breadwinner_pc_internal_id",
              "internalId": "588",
              "fieldType": null
            },
            {
              "valueLookup": null,
              "value": "false",
              "scriptId": "custbody_enableimport",
              "internalId": "691",
              "fieldType": null
            }
          ]
        },
        "currencyRecord": {
          "type": null,
          "name": "INR",
          "internalId": "1",
          "externalId": null
        },
        "currencyName": "INR",
        "createdFrom": null,
        "createdDate": 1682496289,
        "classification": {
          "type": null,
          "name": "Partner Class",
          "internalId": "1",
          "externalId": null
        },
        "applyList": null,
        "applied": null,
        "account": {
          "type": null,
          "name": "Cheque Account",
          "internalId": "1",
          "externalId": null
        }
      }
    ]
  }
}
```
:::





