delete
The delete operation is used to delete an instance of a record. It is similar to the deleteList operation, except that it permits only one record to be deleted per request.
Request
The DeleteRequest type is used for the request. It contains the following fields.
Element Name |
XSD Type |
Notes |
---|---|---|
recordRef |
RecordRef |
Indentifies the record to be deleted. |
deletionReason |
DeletionReason |
Identifies a deletion reason and deletion reason memo. This parameter supports the Use Deletion Reasons feature, which requires users to provide reasons when they delete transactions. However, even when this feature is not enabled, you must use this parameter with every delete request. (You can provide a value of |
Deletion Reason Usage Notes
Note the following about the deletionReason parameter:
-
The deletionReason complex type includes two fields: deletionReasonCode and deletionReasonMemo. The deletionReasonCode must identify a deletion reason that is listed at Setup > Accounting > Accounting Lists. If the Use Deletion Reasons feature is enabled and you use the deletionReasonCode to identify a code that does not exist, the request fails with an
INVALID_REF_KEY
error. -
Deletion reasons can be saved only for transactions. However, in SOAP web services, you must use the deletionReason parameter even when referencing other record types, and even when the Use Deletion Reasons feature is not enabled. For situations where it is not appropriate to identify a deletion reason, pass in a value of
null
. -
Even when when a deletion reason is required, you can use a value of
null
. In these cases, the system automatically populates the deletion reason fields with default values. These defaults are:Other
for deletionReasonCode andThis transaction was deleted by script or web service
for deletionReasonMemo. -
The deletionReason complex type is defined in the core XSD.
For more details about the Use Deletion Reasons feature, see Recording a Reason for Deleting a Transaction.
Response
The DeleteResponse type is used for the response. It contains the following fields.
Element Name |
XSD Type |
Notes |
---|---|---|
response |
WriteResponse |
Contains details on the status of the delete operation and a reference to the deleted record. |
Faults
This operation can throw one of the following faults. See SOAP Fault Status Codes for more information on faults.
-
InvalidSessionFault
-
InvalidCredentialsFault
-
ExceededRequestLimitFault
-
ExceededUsageLimitFault
-
ExceededRecordCountFault
-
ExceededRequestSizeFault
-
UnexpectedErrorFault
If you attempt to delete a record that does not exist, the system returns an INVALID_KEY_OR_REF error.
Sample Code
The following example shows how to delete a cash sale transaction.
C#
private void deleteCashSale()
{
RecordRef myCashSale = new RecordRef();
myCashSale.internalId = "1745";
myCashSale.type = RecordType.cashSale;
myCashSale.typeSpecified = true;
RecordRef myDeletionReasonCode = new RecordRef();
myDeletionReasonCode.internalId = "3";
DeletionReason myDeletionReason = new DeletionReason();
myDeletionReason.deletionReasonCode = myDeletionReasonCode;
myDeletionReason.deletionReasonMemo = "Per John in Accounting";
_service.delete(myCashSale, myDeletionReason);
}
SOAP Request
<soap:Body>
<delete xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
<baseRef type="cashSale" internalId="1745" xsi:type="q1:RecordRef" xmlns:q1="urn:core_2017_1.platform.webservices.netsuite.com"/>
<deletionReason>
<deletionReasonCode internalId="3" xmlns="urn:core_2017_1.platform.webservices.netsuite.com"/>
<deletionReasonMemo xmlns="urn:core_2017_1.platform.webservices.netsuite.com">Per John in Accounting</deletionReasonMemo>
</deletionReason>
</delete>
</soap:Body>
SOAP Response
<soapenv:Body>
<deleteResponse xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
<writeResponse>
<platformCore:status isSuccess="true" xmlns:platformCore="urn:core_2017_1.platform.webservices.netsuite.com"/>
<baseRef xsi:type="platformCore:RecordRef" type="cashSale" internalId="1745" xmlns:platformCore="urn:core_2017_1.platform.webservices.netsuite.com"/>
</writeResponse>
</deleteResponse>
</soapenv:Body>
Related Topics
- Recording a Reason for Deleting a Transaction
- deleteList
- SuiteTalk SOAP Web Services Platform Overview
- SOAP Web Services Development Considerations
- SOAP Web Services Processing
- SOAP Web Services Operations
- SOAP Web Services Standard Operations
- SOAP Web Services List Operations
- SOAP Web Services Asynchronous Operations