Newer Version Available
Execute a SOQL Query that Includes Deleted Items
The following query requests the value from the Name field from all deleted Merchandise__c records, in an organization that has one deleted Merchandise__c record. The same query using Query instead of QueryAll would return no records, because Query automatically filters out any deleted record from the result set.
- Example usage for executing a query for deleted Merchandise__c records
-
1curl https://MyDomainName.my.salesforce.com/services/data/v65.0/queryAll/?q=SELECT+Name+from+Merchandise__c+WHERE+isDeleted+=+TRUE -H "Authorization: Bearer token" - Example request body for executing a query
- none required
- Example response body for executing a query
-
1{ 2 "done" : true, 3 "totalSize" : 1, 4 "records" : 5 [ 6 { 7 "attributes" : 8 { 9 "type" : "Merchandise__c", 10 "url" : "/services/data/v65.0/sobjects/Merchandise__c/a00D0000008pQRAIX2" 11 }, 12 "Name" : "Merchandise 1" 13 }, 14 ] 15}
Retrieving the Remaining SOQL Query Results
1"nextRecordsUrl" : "/services/data/v65.0/query/01gD0000002HU6KIAW-2000"In such cases, request the next batch of records and repeat until all records have been retrieved. These requests use nextRecordsUrl, and do not include any parameters.
Although the nextRecordsUrl has query in the URL, it still provides the remaining results from the initial QueryAll request. The remaining results include deleted records that matched the initial query.
- Example usage for retrieving the remaining results
-
1curl https://MyDomainName.my.salesforce.com/services/data/v65.0/query/01gD0000002HU6KIAW-2000 -H "Authorization: Bearer token" - Example request body for retrieving the remaining results
- none required
- Example response body for retrieving the remaining results
-
1{ 2 "done" : true, 3 "totalSize" : 3214, 4 "records" : [...] 5}