deleteRecord()
The deleteRecord() function (server-side) deletes a NetSuite record using its internal ID and type.
If the correct record type isn't provided, another item type with the same internal ID may be deleted instead. Make sure you provide the correct type to avoid deleting a record unintentionally.
Syntax
Use this syntax for the deleteRecord() function:
deleteRecord({
type: string,
id: number
}).done(callback)
.fail(callback);
Return Value
If the record is deleted successfully, the deleteRecord() function returns a promise that resolves to an object with a data key. This key stores the internal ID of the deleted record as a string. The object returned contains the following information:
{
"data": "recordInternalId"
}
If an error occurs, the promise is rejected with an error object. The error object contains the following information:
{
isError: true,
message: 'Error message'
}
Parameters
All properties are required.
The deleteRecord() function accepts a single object as a parameter. The object includes the following properties:
-
type- Specifies the record type to delete, for example,assemblyitemorinventoryitem. -
id- Specifies the internal ID of the record to delete.
Examples
The following examples show how to use the deleteRecord() function.
Deleting a Record
This example deletes an assembly record with internal ID 444. If the record is successfully deleted, it logs the result; otherwise, it logs fail.
deleteRecord({
type: 'assemblyitem',
id: 444
}).done(function(data) {
console.log(data);
}).fail(function() {
console.log('fail');
});