---
title: Update
slug: netsuite/72CM-update
description: Learn how to update Purchase Orders in NetSuite with this comprehensive document. Discover how to modify fields, add custom fields and line items, and gain insights into the code used for updating Purchase Orders. Get access to valuable information and se
docTags: 
createdAt: 2021-10-26T11:52:35.000Z
---

The following is an example of updating a Purchase Order where we are changing some of the fields. (See [Purchase Order](docId:5hsXRNFvYSvm86EiSMiOi) for all available fields).  The NetSuite Purchase Order Id (internalId) is required to update a Purchase Order.

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

The response returns the complete Purchase Order information but we have shortened the response in our example for ease of reading.

:::CodeblockTabs
Request

```apex
//  Create a Map to store all the data of a Purchase Order
Map<String, Object> nsPurchaseorder = new Map<String, Object>();
	nsPurchaseorder.put('internalId', '120761');
    nsPurchaseorder.put('classification', new Map<String, Object>{'internalId'=>'9'});
    nsPurchaseorder.put('currencyRecord', new Map<String, Object>{'internalId'=>'2'});
    nsPurchaseorder.put('Department', new Map<String, Object>{'internalId'=>'11'});
    nsPurchaseorder.put('entity', new Map<String, Object>{'internalId'=>'108018'});
    nsPurchaseorder.put('memo', 'PO 30');
    nsPurchaseorder.put('otherRefNum', '4343399');
    nsPurchaseorder.put('tranDate', DateTime.newInstance(2023, 04, 28).getTime()/1000);

//  Initializing the Purchase Order Custom Fields
    List<Object> poCustomFieldList = new List<Object>();
    Map<String, Object> poCustomField = new Map<String, Object>();
        poCustomField.put('fieldType', 'select');
        poCustomField.put('scriptId', 'custbody_customlist');
        poCustomField.put('valueLookup', new Map<String, Object>{'internalId'=>'3'});
        poCustomFieldList.add(poCustomField);

//  Adding the Purchase Order Custom Fields
    nsPurchaseorder.put('customFieldList', new Map<String, Object>{'customField'=>poCustomFieldList});

//  Initializing the Purchase 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');
        lineItem.put('item', new Map<String, Object>{'internalId'=>'8823'});
        lineItem.put('quantity', 1);
        lineItem.put('rate', '999');

//  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 Purchase Order Line Item Custom Fields
        lineItem.put('customFieldList', new Map<String, Object>{'customField'=>liCustomFieldList});
        lineItemList.add(lineItem);

//  Adding the Line Items to Purchase Order
    Map<String, Object> poLineitemList = new Map<String, Object>();
        poLineitemList.put('item', lineItemList);
    nsPurchaseorder.put('itemList', poLineitemList);

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

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'updatePurchaseOrder');
    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=updatePurchaseOrder,
  timestamp=1682676021859,
  validRequest=true,
  version=1.0,
  responseJSON={
    "status": "200",
     "errors": [],
    "purchaseOrders": [
      {
        "tranId": "14669",
        "tranDate": 1682650800,
        "trackingNumbers": null,
        "total": 999.0,
        "terms": null,
        "taxTotal": 0.0,
        "subTotal": 999.0,
        "subsidiary": {
          "type": null,
          "name": "Parent Company",
          "internalId": "1",
          "externalId": null
        },
        "status": "Pending Receipt",
        "source": "Web Services",
        "shipTo": null,
        "shippingAddress": null,
        "shipMethod": null,
        "shipDate": null,
        "salesforceID": "a0V1e000003bajtEAA",
        "otherRefNum": "4343399",
        "nullFieldList": null,
        "memo": "PO 30",
        "location": null,
        "lastModifiedDate": 1682676018,
        "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": "999.00",
              "quantityRemaining": null,
              "quantityReceived": 0.0,
              "quantityPicked": null,
              "quantityPacked": null,
              "quantityOnHand": null,
              "quantityFulfilled": null,
              "quantityCommitted": null,
              "quantityBilled": 0.0,
              "quantityBackOrdered": null,
              "quantityAvailable": null,
              "quantity": 1.0,
              "price": null,
              "poNum": null,
              "percentComplete": null,
              "orderLine": null,
              "onHand": null,
              "location": null,
              "line": 4,
              "jobName": null,
              "itemReceive": null,
              "itemName": null,
              "itemIsFulfilled": null,
              "item": {
                "type": null,
                "name": "Blue Jeans",
                "internalId": "8823",
                "externalId": null
              },
              "isClosed": false,
              "grossAmt": 999.0,
              "expectedReceiptDate": 1682650800,
              "description": "A weapon for shooting arrows",
              "department": null,
              "customFieldList": {
                "customField": [
                  {
                    "valueLookup": null,
                    "value": "1",
                    "scriptId": "custcol_gh_line_no",
                    "internalId": "175",
                    "fieldType": null
                  },
                  {
                    "valueLookup": null,
                    "value": "false",
                    "scriptId": "custcol_checkbox",
                    "internalId": "443",
                    "fieldType": null
                  },
                  {
                    "valueLookup": null,
                    "value": "ERROR: Field 'custcol7' Not Found",
                    "scriptId": "custcol11",
                    "internalId": "656",
                    "fieldType": null
                  }
                ]
              },
              "createPo": null,
              "costEstimateType": null,
              "costEstimate": null,
              "classification": null,
              "billingSchedule": null,
              "amount": 999.0
            }
          ]
        },
        "internalId": "120761",
        "fax": null,
        "externalId": null,
        "expenseList": null,
        "exchangeRate": 23.0,
        "entity": {
          "type": null,
          "name": "Edge Communications-1",
          "internalId": "108018",
          "externalId": null
        },
        "employee": null,
        "email": null,
        "dueDate": null,
        "department": {
          "type": null,
          "name": "Space Exploratory",
          "internalId": "11",
          "externalId": null
        },
        "customForm": {
          "type": null,
          "name": "Standard Purchase Order",
          "internalId": "98",
          "externalId": null
        },
        "customFieldList": {
          "customField": [
            {
              "valueLookup": null,
              "value": "false",
              "scriptId": "custbody34",
              "internalId": "558",
              "fieldType": null
            },
            {
              "valueLookup": null,
              "value": " - ",
              "scriptId": "custbody_breadwinner_pc_internal_id",
              "internalId": "588",
              "fieldType": null
            },
            {
              "valueLookup": {
                "type": null,
                "name": "C",
                "internalId": "3",
                "externalId": null
              },
              "value": null,
              "scriptId": "custbody_customlist",
              "internalId": "458",
              "fieldType": null
            },
            {
              "valueLookup": null,
              "value": "false",
              "scriptId": "custbody_checkbox",
              "internalId": "272",
              "fieldType": null
            },
            {
              "valueLookup": null,
              "value": "false",
              "scriptId": "custbody_enableimport",
              "internalId": "691",
              "fieldType": null
            }
          ]
        },
        "currencyRecord": {
          "type": null,
          "name": "US Dollars",
          "internalId": "2",
          "externalId": null
        },
        "currencyName": "US Dollars",
        "createdFrom": null,
        "createdDate": 1681902033,
        "classification": {
          "type": null,
          "name": "Rocket Science",
          "internalId": "9",
          "externalId": null
        },
        "billingAddress": {
          "zip": null,
          "state": "TX",
          "internalId": null,
          "country": "_india",
          "city": "Austin",
          "attention": null,
          "addrPhone": null,
          "addressee": "Edge Communications-1",
          "addr3": null,
          "addr2": null,
          "addr1": "312 Constitution Place Austin, TX 78767 USA"
        }
      }
    ]
  }
}
```
:::

