---
title: Update
slug: netsuite/uq0m-update
description: Learn how to update a Sales Order in NetSuite with this comprehensive document. Explore the included code snippets in Apex programming language, which showcase how to modify different fields, such as custom fields and line items. Understand that only one 
docTags: 
createdAt: 2021-10-26T11:52:35.000Z
---

The following is an example of update SalesOrder where we are changing some of the fields . (See [SalesOrder](docId\:EmQjIKnClZE-b-zi9PinN) for all available fields).  The NetSuite Sales Order Id (internalId) is required to update the Sales Order.

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

The response returns the complete Sales Order 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 Sales Order
Map<String, Object> nsSalesOrder = new Map<String, Object>();
nsSalesOrder.put('internalId', '83943');
nsSalesOrder.put('classification', new Map<String, Object>{'internalId'=>'2'});
nsSalesOrder.put('currencyRecord', new Map<String, Object>{'internalId'=>'1'});
nsSalesOrder.put('department', new Map<String, Object>{'internalId'=>'1'});
nsSalesOrder.put('discountItem', new Map<String, Object>{'internalId'=>'-6'});
nsSalesOrder.put('discountRate', '-20');
nsSalesOrder.put('entity', new Map<String, Object>{'internalId'=>'362'});
nsSalesOrder.put('memo', 'Order 30');
nsSalesOrder.put('otherRefNum', '4343390');
nsSalesOrder.put('tranDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);

// Initialize the Sales Order Custom Fields
List<Object> soCustomFieldList = new List<Object>();
Map<String,Object> soCustomField = new Map<String,Object>();
soCustomField.put('fieldType', 'select');
soCustomField.put('scriptId', 'custbody_customlist');
soCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'2'});
soCustomFieldList.add(soCustomField);

// Add the Sales Order Custom Fields
nsSalesOrder.put('customFieldList', new Map<String,Object>{'customField'=>soCustomFieldList});

// Initialize the Sales Order Line Items
List<Object> lineItemList = new List<Object>();
Map<String, Object> lineItem = new Map<String, Object>();
lineItem.put('description', 'A weapon for shooting arrows test');
lineItem.put('item', new Map<String, Object>{'internalId'=>'239'});  
lineItem.put('amount', 10);
lineItem.put('quantity', 2);
lineItem.put('grossAmt', 220);
lineItem.put('tax1Amt', 210);
lineItem.put('taxRate1', 1);
lineItem.put('revRecEndDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);
lineItem.put('revRecStartDate', DateTime.newInstance(2021, 09, 07).getTime()/1000);


// Initialize 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', 'custbody_checkbox');
liCustomField.put('value', 'true');
liCustomFieldList.add(liCustomField);

// Addg the Sales Order Line Item Custom Fields
lineItem.put('customFieldList',new Map<String,Object>{'customField'=>liCustomFieldList});
lineItemList.add(lineItem);

// Addg the Line Items to Sales Order
Map<String, Object> soLineitemList = new Map<String, Object>();
soLineitemList.put('item',lineItemList);
soLineitemList.put('replaceAll', false); 
 nsSalesOrder.put('itemList',soLineitemList);

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

Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'updateSalesOrder');
reqObj.put('requestJSON', reqJSON);

// Place a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);
```

Response

```json
{
  action = updateSalesOrder,
  timestamp = 1621491360689,
  validRequest = true,
  version = 1.0,
  responseJSON = {
  "status": "200",
  "errors": [],
  "salesOrders": [
    {
      "tranId": "1",
      "tranDate": 1630953000,
      "total": 199.8,
      "taxTotal": 1.98,
      "subTotal": 217.82,
      "subsidiary": {
        "type": null,
        "name": "Parent Company",
        "internalId": "1",
        "externalId": null
      },
      "status": "Pending Approval",
      "shippingCost": null,
      "shippingAddress": {
        "zip": "94567",
        "state": "CA",
        "internalId": null,
        "country": "_unitedStates",
        "city": "Pope Valley",
        "attention": null,
        "addrPhone": null,
        "addressee": "Atherton Grocery",
        "addr3": null,
        "addr2": "Palo Alto",
        "addr1": null
      },
      "shipAddressList": {
        "type": null,
        "name": "Unnamed Address",
        "internalId": "212",
        "externalId": null
      },
      "salesRep": null,
      "salesforceID": "a0N5Y00000XLadRUAT",
      "otherRefNum": "4343390",
      "nullFieldList": null,
      "memo": "Order 30",
      "location": null,
      "lastModifiedDate": 1621491357,
      "itemList": {
        "replaceAll": null,
        "item": [
          {
            "unitsDisplay": null,
            "taxRate1": "1.0",
            "taxCode": {
              "type": null,
              "name": "VAT_IN:UNDEF-IN",
              "internalId": "5",
              "externalId": null
            },
            "tax1Amt": 2.18,
            "shipMethod": null,
            "shipGroup": null,
            "serialNumbers": null,
            "revRecStartDate": null,
            "revRecSchedule": null,
            "revRecEndDate": null,
            "rate": "100.00",
            "quantityRemaining": null,
            "quantityReceived": null,
            "quantityBilled": 0,
            "quantity": 2,
            "price": {
              "type": null,
              "name": "Base Price",
              "internalId": "1",
              "externalId": null
            },
            "poNum": null,
            "orderLine": null,
            "onHand": null,
            "location": null,
            "line": 38,
            "jobName": null,
            "itemReceive": null,
            "itemName": null,
            "itemIsFulfilled": null,
            "item": {
              "type": null,
              "name": "Bow",
              "internalId": "239",
              "externalId": null
            },
            "grossAmt": 220,
            "expectedReceiptDate": null,
            "description": "A weapon for shooting arrows test",
            "department": null,
            "customFieldList": {
              "customField": [
                {
                  "valueLookup": null,
                  "value": "1",
                  "scriptId": "custcol_gh_line_no",
                  "internalId": "175",
                  "fieldType": null
                }
              ]
            },
            "createPo": "_dropShipment",
            "costEstimateType": null,
            "costEstimate": null,
            "classification": null,
            "amount": 217.82
          }
        ]
      },
      "internalId": "83943",
      "handlingCost": null,
      "externalId": "1",
      "exchangeRate": 1,
      "entity": {
        "type": null,
        "name": "21 Atherton Grocery",
        "internalId": "362",
        "externalId": null
      },
      "discountTotal": -20,
      "discountRate": "-20.00",
      "discountItem": {
        "type": null,
        "name": "Partner Discount",
        "internalId": "-6",
        "externalId": null
      },
      "department": {
        "type": null,
        "name": "PR Department",
        "internalId": "1",
        "externalId": null
      },
      "customForm": {
        "type": null,
        "name": "Custom Sales Order 2",
        "internalId": "121",
        "externalId": null
      },
      "customFieldList": {
        "customField": [
          {
            "valueLookup": null,
            "value": " - ",
            "scriptId": "custbody_breadwinner_pc_internal_id",
            "internalId": "299",
            "fieldType": null
          },
          {
            "valueLookup": null,
            "value": "false",
            "scriptId": "custbody23",
            "internalId": "271",
            "fieldType": null
          },
          {
            "valueLookup": null,
            "value": "2021-05-19 23:15:57",
            "scriptId": "custbodylastmodifieddate",
            "internalId": "298",
            "fieldType": null
          }
        ]
      },
      "currencyRecord": null,
      "currencyName": "INR",
      "createdFrom": null,
      "createdDate": 1620386017,
      "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": "Atherton Grocery",
        "addr3": null,
        "addr2": "Palo Alto",
        "addr1": null
      },
      "billAddressList": {
        "type": null,
        "name": "Unnamed Address",
        "internalId": "212",
        "externalId": null
      }
    }
  ]
 }
}
```
:::



