---
title: Create
slug: netsuite/hD4C-create
description: Learn how to create a cash refund in NetSuite using the "createCashSale" action and passing the required data in the request JSON. Get an example code that sets various fields and discover the response from NetSuite, including the new NetSuite Cash Sale I
docTags: 
createdAt: 2021-12-14T13:05:36.000Z
---

To create a Cash Refund in NetSuite, use action as "createCashSale" and pass the Cash Sale data in the requestJSON under "cashSales".

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

The following is an example of create CashSale where we are setting every possible field (See [﻿](https://app.archbee.io/docs/-LIHUUnv_7XNQrtzHsKkC/hnjmkN99QxWdEafyYIFSq)[Cash Sale](docId\:RWxpkW_L-gVoUpv_njVbc) for the available fields).  The response will return the response back from NetSuite, which includes the new NetSuite Cash Sale Id (internalId), plus the newly created Salesforce ﻿Cash Sale Id (salesforceID)

:::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('classification', new Map<String, Object>{'internalId'=>'5'});
    nsCashSale.put('department', new Map<String, Object>{'internalId'=>'1'});
	nsCashSale.put('entity', new Map<String, Object>{'internalId'=>'362'});
	nsCashSale.put('location',new Map<String, Object>{'internalId'=>'1'});
	nsCashSale.put('memo', 'Cash Sale 300');
    nsCashSale.put('otherRefNum', '4343400');
    nsCashSale.put('tranDate', DateTime.newInstance(2020, 10, 07).getTime()/1000);
//  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', 'true');
        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('item', new Map<String, Object>{'internalId'=>'239'});
        lineItem.put('quantity', 4);
		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 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);
    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', 'createCashSale');
    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=createCashSale,
   timestamp=1639549899627,
   validRequest=true,
   version=1.0,
    responseJSON={
      "errors":[],
      "status":"200",  
      "CashSales":[
         {
            "undepFunds":true,
            "tranId":"11",
            "tranDate":1601956800,
            "total":16.0,
            "terms":null,
            "taxTotal":0.0,
            "subTotal":16.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":"a0B0l00000AvFRGEA3",
            "otherRefNum":"4343400",
            "nullFieldList":null,
            "memo":"Cash Sale 300",
            "location":{
               "type":null,
               "name":"test : Atlanta west",
               "internalId":"1",
               "externalId":null
            },
            "lastModifiedDate":1639549869,
            "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":4.0,
                     "price":{
                        "type":null,
                        "name":"Base Price",
                        "internalId":"1",
                        "externalId":null
                     },
                     "poNum":null,
                     "orderLine":null,
                     "onHand":null,
                     "location":null,
                     "line":2,
                     "jobName":null,
                     "itemReceive":null,
                     "itemName":null,
                     "itemIsFulfilled":null,
                     "item":{
                        "type":null,
                        "name":"Bow",
                        "internalId":"239",
                        "externalId":null
                     },
                     "grossAmt":8.0,
                     "expectedReceiptDate":null,
                     "description":null,
                     "department":null,
                     "customFieldList":{
                        "customField":[
                           {
                              "valueLookup":null,
                              "value":"false",
                              "scriptId":"custcol_checkbox",
                              "internalId":"443",
                              "fieldType":null
                           }
                        ]
                     },
                     "createPo":null,
                     "costEstimateType":null,
                     "costEstimate":null,
                     "classification":null,
                     "amount":8.0
                  }
               ]
            },
            "internalId":"91603",
            "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":"true",
                     "scriptId":"custbody_checkbox",
                     "internalId":"272",
                     "fieldType":null
                  }
               ]
            },
            "currencyRecord":{
               "type":null,
               "name":"US Dollars",
               "internalId":"2",
               "externalId":null
            },
            "currencyName":"US Dollars",
            "createdFrom":null,
            "createdDate":1639549869,
            "classification":{
               "type":null,
               "name":"Corporate Sales",
               "internalId":"5",
               "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
         }
      ]
   }
}
```
:::

