Reputation: 181
I have loaded my Salesforce object data into Azure SQL. Now I want that one or multiple record in Salesforce get deleted then I can retrieve those records using REST API.
Is there any way to create REST API for those records for particular object?
Upvotes: 1
Views: 1818
Reputation: 19637
"Yes, but".
By default SF soft deletes the records, they can still be seen in UI in Recycle Bin and undeleted from there. (There's also a hard delete call to skip the Recycle Bin).
Records stay in there for 15 days max. And bin's capacity depends on your org's data storage, see https://help.salesforce.com/articleView?id=home_delete.htm&type=5. So if you mass deleted a lot of data there's chance the bin will overflow.
To retrieve these you need to call /queryAll
instead of /query
service. And filter by isDeleted
column which doesn't show up in Setup but is on pretty much every object. See https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_queryall.htm
/services/data/v49.0/queryAll/?q=SELECT+Name+from+Account+WHERE+isDeleted+=+TRUE
If this is not good enough for you, if you risk the Bin overflows or the operation was hard delete - you could make your own soft delete (move records to some special owner outside of role hierarchy so they become invisible to everybody except sysadmins?) or change strategy. Push info from SF instead of pulling. Send a platform even on delete, manual or with Change Data Capture. (I think CDC doesn't generate events on hard delete though, you'd have to read up)
Upvotes: 1