You use the getDeleted operation to retrieve a list of deleted records. When you use this operation, you can filter by record type, by script ID, and by the date of record deletion. For each record that matches the filter criteria, the system returns the following data:
- The record’s type
- The record’s name
- The record’s internal ID
- The record’s external ID (if available)
- The date the record was deleted
The getDeleted operation can be useful when you want to synchronize information in a client application with NetSuite. For example, an Outlook client application plug-in maintains a list of contacts and synchronizes that list with NetSuite. The getDeleted operation can be used to determine contact deletions since the last synchronization with NetSuite.
Permissions
By default, only account administrators and users with the Full Access role have permission to use the getDeleted operation. However, you can grant permission to other roles. To use the getDeleted operation, the role has to have the Deleted Records permission (and the Web Services permission).
Users who have the Deleted Records permission can access results about any type of record that was deleted, even if they do not have permission to create or modify that record type. They also have permission to use the Deleted Record search type in the user interface, unless the Web Services Only option has been selected for the role.
You can give a role the Deleted Records permission by going to Setup > Users/Roles > Manage Roles. Go to the Permissions > Setup subtab, and add a line for the permission.
Request
<soapenv:Envelope
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:platformCore='urn:core_2021_2.platform.webservices.netsuite.com'
xmlns:listRel='urn:relationships_2021_2.lists.webservices.netsuite.com'
xmlns:listAcct='urn:accounting_2021_2.lists.webservices.netsuite.com'
xmlns:platformMsgs='urn:messages_2021_2.platform.webservices.netsuite.com'>
<soapenv:Header>
<tokenPassport xsi:type='platformCore:TokenPassport'>
<account xsi:type='xsd:string'>{{accountId}}</account>
<consumerKey xsi:type='xsd:string'>{{consumerKey}}</consumerKey>
<token xsi:type='xsd:string'>{{tokenId}}</token>
<nonce xsi:type='xsd:string'>{{nonce}}</nonce>
<timestamp xsi:type='xsd:long'>{{timestamp}}</timestamp>
<signature algorithm='HMAC_SHA256' xsi:type='platformCore:TokenPassportSignature'>{{signature}}</signature>
</tokenPassport>
</soapenv:Header>
<soapenv:Body>
<getDeleted xsi:type='platformMsgs:GetDeletedRequest'>
<getDeletedFilter xsi:type='platformCore:GetDeletedFilter'>
<deletedDate operator='after' xsi:type='platformCore:SearchDateField'>
<searchValue xsi:type='xsd:dateTime'>2023-07-01T05:00:53.721Z</searchValue>
<searchValue2 xsi:type='xsd:dateTime'>2023-08-07T05:00:53.721Z</searchValue2>
</deletedDate>
</getDeletedFilter>
<pageIndex xsi:type='xsd:int'>1</pageIndex>
</getDeleted>
</soapenv:Body>
</soapenv:Envelope>
Response
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<platformMsgs:documentInfo
xmlns:platformMsgs="urn:messages_2021_2.platform.webservices.netsuite.com">
<platformMsgs:nsId>WEBSERVICES_TSTDRV2782962_080620238324705861261631591_dc3045</platformMsgs:nsId>
</platformMsgs:documentInfo>
</soapenv:Header>
<soapenv:Body>
<getDeletedResponse
xmlns="">
<platformCore:getDeletedResult
xmlns:platformCore="urn:core_2021_2.platform.webservices.netsuite.com">
<platformCore:status isSuccess="true"/>
<platformCore:totalRecords>5</platformCore:totalRecords>
<platformCore:pageSize>1000</platformCore:pageSize>
<platformCore:totalPages>1</platformCore:totalPages>
<platformCore:pageIndex>1</platformCore:pageIndex>
<platformCore:deletedRecordList>
<platformCore:deletedRecord>
<platformCore:deletedDate>2023-08-01T05:24:46.000-07:00</platformCore:deletedDate>
<platformCore:record internalId="127" type="customer" xsi:type="platformCore:RecordRef">
<platformCore:name>4 Test Developer</platformCore:name>
</platformCore:record>
</platformCore:deletedRecord>
<platformCore:deletedRecord>
<platformCore:deletedDate>2023-08-01T05:24:46.000-07:00</platformCore:deletedDate>
<platformCore:record internalId="14" type="customerSubsidiaryRelationship" xsi:type="platformCore:RecordRef">
<platformCore:name>14</platformCore:name>
</platformCore:record>
</platformCore:deletedRecord>
<platformCore:deletedRecord>
<platformCore:deletedDate>2023-08-01T05:24:48.000-07:00</platformCore:deletedDate>
<platformCore:record internalId="27" type="contact" xsi:type="platformCore:RecordRef">
<platformCore:name>2 Test Employee</platformCore:name>
</platformCore:record>
</platformCore:deletedRecord>
<platformCore:deletedRecord>
<platformCore:deletedDate>2023-08-01T05:24:47.000-07:00</platformCore:deletedDate>
<platformCore:record internalId="27" type="employee" xsi:type="platformCore:RecordRef">
<platformCore:name>2 Test Employee</platformCore:name>
</platformCore:record>
</platformCore:deletedRecord>
<platformCore:deletedRecord>
<platformCore:deletedDate>2023-08-04T10:02:38.000-07:00</platformCore:deletedDate>
<platformCore:record internalId="882" type="file" xsi:type="platformCore:RecordRef">
<platformCore:name>ECSI-2 JS Add Multiple items (2).js</platformCore:name>
</platformCore:record>
</platformCore:deletedRecord>
</platformCore:deletedRecordList>
</platformCore:getDeletedResult>
</getDeletedResponse>
</soapenv:Body>
</soapenv:Envelope>