---
title: Create
slug: netsuite/yu2C-create
description: Learn how to create an Invoice in NetSuite using the "createInvoice" action with this comprehensive guide. It features a code snippet example to help you understand how to set up various fields, including classification, currency, department, entity, loca
docTags: 
createdAt: 2021-12-14T12:51:15.000Z
---

To create an Invoice in NetSuite, use action as "createInvoice" and pass the Invoice data in the requestJSON under "invoices".

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

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


:::CodeblockTabs
Request

```apex
//Create a Map to store all the data of a Invoice
Map<String, Object> nsInvoice = new Map<String, Object>();
    nsInvoice.put('classification', new Map<String, Object>{'internalId'=>'5'});
    nsInvoice.put('currencyRecord', new Map<String, Object>{'internalId'=>'2'});
    nsInvoice.put('department', new Map<String, Object>{'internalId'=>'2'});
    nsInvoice.put('entity', new Map<String, Object>{'internalId'=>'362'});
	nsInvoice.put('location',new Map<String, Object>{'internalId'=>'1'});    
	nsInvoice.put('memo', 'Invoice 100');
    nsInvoice.put('otherRefNum', '4343399');
    nsInvoice.put('tranDate', DateTime.newInstance(2020, 09, 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', 'select');
        invCustomField.put('scriptId', 'custbody_customlist');
        invCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'2'});
        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', 'A weapon for shooting arrows');
        lineItem.put('item', new Map<String, Object>{'internalId'=>'239'});
        lineItem.put('quantity', 3);
//  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 Invoice Line Item Custom Fields
        lineItem.put('customFieldList', new Map<String, Object>{'customField'=>liCustomFieldList});
        lineItemList.add(lineItem);

//  Adding the Line Items to Invoice
    Map<String, Object> invLineitemList = new Map<String, Object>();
        invLineitemList.put('item', lineItemList);
    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', 'createInvoice');
    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=createInvoice,
   timestamp=1639471468356,
   validRequest=true,
   version=1.0,
   responseJSON={
      "errors":[],
      "status":"200",
      "invoices":[
         {
            "undepFunds":null,
            "tranId":"INV429",
            "tranDate":1599364800,
            "total":6.0,
            "terms":null,
            "taxTotal":0.0,
            "subTotal":6.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":"a0B0l00000AvEODEA3",
            "otherRefNum":"4343399",
            "nullFieldList":null,
            "memo":"Invoice 100",
            "location":{
               "type":null,
               "name":"test : Atlanta west",
               "internalId":"1",
               "externalId":null
            },
            "lastModifiedDate":1639471436,
            "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":3.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":6.0,
                     "expectedReceiptDate":null,
                     "description":"A weapon 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":6.0
                  }
               ]
            },
            "internalId":"91303",
            "handlingCost":null,
            "externalId":null,
            "exchangeRate":1.0,
            "entity":{
               "type":null,
               "name":"21 Atherton Grocery",
               "internalId":"362",
               "externalId":null
            },
            "dueDate":1599364800,
            "discountTotal":0.0,
            "discountRate":null,
            "discountItem":null,
            "department":{
               "type":null,
               "name":"Sales",
               "internalId":"2",
               "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":"false",
                     "scriptId":"custbody_checkbox",
                     "internalId":"272",
                     "fieldType":null
                  }
               ]
            },
            "currencyRecord":{
               "type":null,
               "name":"US Dollars",
               "internalId":"2",
               "externalId":null
            },
            "currencyName":"US Dollars",
            "createdFrom":null,
            "createdDate":1639471436,
            "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":{
               "type":null,
               "name":"Accounts Receivable",
               "internalId":"122",
               "externalId":null
            }
         }
      ]
   }
}

```
:::



