Transforming Records

In REST web services, you can transform a record from one type into an another, using data from an existing records. For example, you can create an invoice record from an existing sales order record, using data from the sales order.

All record transformations available in SuiteScript are available in REST web services, too. Transformations are also supported in metadata. For information about the supported transformation types, see record.transform(options).

Record transformation is generally available for supported records. For a list of fully supported records, you can also see REST Web Services Supported Records.

In REST web services, you use the POST method to send a record transformation request. The record transformation is executed in a single request. In the request URL, the following details must be specified:

In the following example, a sales order record is transformed into an invoice. If the transformation is performed successfully, an HTTP 204 – No Content response is returned.

          POST http://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/salesOrder/3/!transform/invoice 

        

In the request body, you can also specify data for additional fields of the record, as shown in the following example.

          {
   "memo": "REST, end date and bills date added",
   "enddate": "2020-01-14",
   "billdate": "2020-01-14",
   "item": {
      "items": [
         { 
            "item": { "id": "3456" },
            "amount": 1 
         }
      ]
   }
} 

        

In the following example, an invoice is transformed into a credit memo. Note that you must specify the doc field, which contains the internal id of the invoice.

          POST  http://demo123.suitetalk.api.netsuite.com/services/rest/record/v1/invoice/60/!transform/creditMemo

{
    "toBeEmailed":false,
    "apply":{
        "items" :
        [
             {
                "line": 0,
                "amount":3.01,
                "apply": true,
                "applyDate": "2023-09-12",
                "doc": {"id" : "60"}
            }
        ]
    }
} 

        

Related Topics

General Notices