---
title: Create
slug: netsuite/v44h-create
description: Learn how to create a Purchase Order in NetSuite using the "createPurchaseOrder" action and requestJSON. This document covers the step-by-step process and includes a sample Purchase Order with filled fields. Get detailed instructions and discover the new 
docTags: 
createdAt: 2021-10-26T11:39:15.000Z
---

To create a Purchase Order in NetSuite, use action as "createPurchaseOrder" and pass the Purchase Order data in the requestJSON under "purchaseOrders".

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

The following is an example of create Purchase Order where we are setting every possible field (See [Purchase Order](docId:8alJK2Kh41UJg328KlGjY) for the available fields).  The response will return the response back from NetSuite, which includes the new NetSuite Purchase Order Id (internalId), plus the newly created Salesforce ﻿Purchase Order Id (salesforceID)

:::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('classification', new Map<String, Object>{'internalId'=>'5'});
    nsPurchaseorder.put('currencyRecord', new Map<String, Object>{'internalId'=>'1'});
    nsPurchaseorder.put('department', new Map<String, Object>{'internalId'=>'2'});
    nsPurchaseorder.put('dueDate', DateTime.newInstance(2020, 12, 31).getTime()/1000);
    nsPurchaseorder.put('entity', new Map<String, Object>{'internalId'=>'30440'});
    nsPurchaseorder.put('shipTo', new Map<String, Object>{'internalId'=>'362'});
    nsPurchaseorder.put('memo', 'PO 12');
    nsPurchaseorder.put('otherRefNum', '4343399');
    nsPurchaseorder.put('tranDate', DateTime.newInstance(2020, 09, 07).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'=>'2'});
        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'=>'239'});
        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', 'true');
            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', 'createPurchaseOrder');
    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=createPurchaseOrder,
  timestamp=1606481122212,
  validRequest=true,
  version=1.0,
  responseJSON={
    "status": "200",
    "errors": [],
    "purchaseOrders": [
      {
        "tranId": "360",
        "tranDate": 1599417000,
        "trackingNumbers": null,
        "total": 1178.82,
        "terms": null,
        "taxTotal": 179.82,
        "subTotal": 999.0,
        "subsidiary": {
          "type": null,
          "name": "Parent Company",
          "internalId": "1",
          "externalId": null
        },
        "status": "Pending Receipt",
        "source": "Web Services",
        "shipTo": {
          "type": null,
          "name": "21 Atherton Grocery",
          "internalId": "362",
          "externalId": null
        },
        "shippingAddress": {
          "zip": "94567",
          "state": "CA",
          "internalId": null,
          "country": "_unitedStates",
          "city": "Pope Valley",
          "attention": null,
          "addrPhone": null,
          "addressee": null,
          "addr3": null,
          "addr2": "Palo Alto",
          "addr1": null
        },
        "shipMethod": null,
        "shipDate": 1606415400,
        "salesforceID": "a0O2w000001rix8EAA",
        "otherRefNum": "4343399",
        "nullFieldList": null,
        "memo": "PO 12",
        "location": null,
        "lastModifiedDate": 1606481119,
        "itemList": {
          "replaceAll": null,
          "item": [
            {
              "unitsDisplay": null,
              "taxRate1": "18.0",
              "taxCode": {
                "type": null,
                "name": "VAT_IN:GST 18",
                "internalId": "36",
                "externalId": null
              },
              "tax1Amt": 179.82,
              "shipMethod": null,
              "shipGroup": null,
              "serialNumbers": null,
              "revRecStartDate": null,
              "revRecSchedule": null,
              "revRecEndDate": null,
              "rate": "999.00",
              "quantityRemaining": null,
              "quantityReceived": 0.0,
              "quantityBilled": 0.0,
              "quantity": 1.0,
              "price": 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": 1178.82,
              "expectedReceiptDate": 1599417000,
              "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": "true",
                    "scriptId": "custcol_checkbox",
                    "internalId": "443",
                    "fieldType": null
                  }
                ]
              },
              "createPo": null,
              "costEstimateType": null,
              "costEstimate": null,
              "classification": null,
              "amount": 999.0
            }
          ]
        },
        "internalId": "54653",
        "fax": null,
        "externalId": null,
        "exchangeRate": 1.0,
        "entity": {
          "type": null,
          "name": "RM Textiles",
          "internalId": "30440",
          "externalId": null
        },
        "employee": null,
        "email": null,
        "dueDate": 1609353000,
        "department": {
          "type": null,
          "name": "Sales",
          "internalId": "2",
          "externalId": null
        },
        "customForm": {
          "type": null,
          "name": "Custom Drop Ship Purchase Order 6",
          "internalId": "119",
          "externalId": null
        },
        "customFieldList": {
          "customField": [
            {
              "valueLookup": null,
              "value": "false",
              "scriptId": "custbody34",
              "internalId": "558",
              "fieldType": null
            },
            {
              "valueLookup": {
                "type": null,
                "name": "B",
                "internalId": "2",
                "externalId": null
              },
              "value": null,
              "scriptId": "custbody_customlist",
              "internalId": "458",
              "fieldType": null
            }
          ]
        },
        "currencyRecord": null,
        "currencyName": "INR",
        "createdFrom": null,
        "createdDate": 1606481118,
        "classification": {
          "type": null,
          "name": "Corporate Sales",
          "internalId": "5",
          "externalId": null
        },
        "billingAddress": null
      }
    ]
  }
}
```
:::

