---
title: Create
slug: netsuite/Haah-create
description: Learn how to create a Cash Refund in NetSuite using the "createCashRefund" action and passing the required data in the requestJSON. This document provides step-by-step instructions and example code for setting fields like classification, department, entit
docTags: 
createdAt: 2023-04-25T05:39:33.000Z
---

To create a Cash Refund in NetSuite, use action as "createCashRefund" and pass the Cash Refund data in the requestJSON under "cashRefunds".

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

The following is an example of creating a Cash Refund where we are setting every possible field (see [Cash Refund](docId\:t-olxh_QNY0viZ7Wp1CvJ) for the available fields).  The response will return the response back from NetSuite, which includes NetSuite ﻿Cash Refund Id (internalId), plus the newly created Salesforce ﻿Cash Refund Id (salesforceID)

:::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('classification', new Map<String, Object>{'internalId'=>'5'});
    nsCashRefund.put('department', new Map<String, Object>{'internalId'=>'1'});
	nsCashRefund.put('entity', new Map<String, Object>{'internalId'=>'109118'});
	nsCashRefund.put('location',new Map<String, Object>{'internalId'=>'10'});
	nsCashRefund.put('memo', 'Cash Refund 300');
    nsCashRefund.put('otherRefNum', '4343400');
    nsCashRefund.put('tranDate', DateTime.newInstance(2023, 04, 26).getTime()/1000);
//  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_enableimport');
        crCustomField.put('value', 'true');
        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('item', new Map<String, Object>{'internalId'=>'8823'});
        lineItem.put('quantity', 4);
		lineItem.put('Amount', 500);
		lineItem.put('revRecEndDate', DateTime.newInstance(2024, 04, 26).getTime()/1000);
        lineItem.put('revRecStartDate', DateTime.newInstance(2024, 04, 26).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 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);
    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', 'createCashRefund');
    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=createCashRefund,
  timestamp= 1682496292136,
  validRequest=true,
  version=1.0,
  responseJSON={
	"errors": [],
	"status": "200",
	"CashRefunds": [{
		"tranId": "16",
		"tranDate": 1682478000,
		"total": 500.0,
		"taxTotal": 0.0,
		"subTotal": 500.0,
		"subsidiary": {
			"type": null,
			"name": "Parent Company",
			"internalId": "1",
			"externalId": null
		},
		"status": null,
		"shippingCost": 0.0,
		"salesRep": null,
		"salesforceID": "a061e000003Ux0KAAS",
		"refundCheck": false,
		"otherRefNum": "4343400",
		"memo": "Cash Refund 300",
		"location": {
			"type": null,
			"name": "Hyderabad : Hi-Tech City",
			"internalId": "10",
			"externalId": null
		},
		"lastModifiedDate": 1682496289,
		"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": 4.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": 500.0,
				"expectedReceiptDate": null,
				"description": "Anything",
				"department": null,
				"customFieldList": {
					"customField": [{
						"valueLookup": null,
						"value": "false",
						"scriptId": "custcol_checkbox",
						"internalId": "443",
						"fieldType": null
					}]
				},
				"createPo": null,
				"costEstimateType": "_lastPurchasePrice",
				"costEstimate": 0.0,
				"classification": null,
				"billingSchedule": null,
				"amount": 500.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": "PR Department",
			"internalId": "1",
			"externalId": null
		},
		"customForm": {
			"type": null,
			"name": "Custom Cash Refund",
			"internalId": "128",
			"externalId": null
		},
		"customFieldList": {
			"customField": [{
					"valueLookup": null,
					"value": "500",
					"scriptId": "custbody42",
					"internalId": "869",
					"fieldType": null
				},
				{
					"valueLookup": null,
					"value": " - ",
					"scriptId": "custbody_breadwinner_pc_internal_id",
					"internalId": "588",
					"fieldType": null
				},
				{
					"valueLookup": null,
					"value": "true",
					"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": "Corporate Sales",
			"internalId": "5",
			"externalId": null
		},
		"applyList": null,
		"applied": null,
		"account": {
			"type": null,
			"name": "Cheque Account",
			"internalId": "1",
			"externalId": null
		}
	}]
}
}
```
:::

