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:
-
The record type you that you want to transform.
-
The ID of the record that you want to transform.
-
The transformation action. The transformation action must be formatted in the following way in the URL:
!transform
. -
The record type you that you want transform into.
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
- The REST API Browser
- NetSuite Record Structure
- Using CRUD Operations on Custom Records, Custom Lists, and Custom Transactions v1
- Creating a Record Instance
- Getting a Record Instance
- Updating a Record Instance
- Using the Upsert Operation
- Deleting a Record Instance
- Accessing Subresources in REST Web Services
- Using External IDs
- Using Datetime Fields
- Executing Record Actions
- Working with the Pricing Sublist on Item Records
- Using the REST Web Services SuiteScript Execution Context