Sunday, 20 October 2013

Deletion Service in MSCRM 2011

Deletion service under CRM 4.0
All deleted records or entities under CRM 4.0 will not be directly deleted. Instead CRM will mark the objects in first step as “marked for deletion”.  As a result, the marked objects could no longer be accessed by the web application or through SDK web service calls. This is called as “soft delete” and will be implemented by changing the objects attribute DeletionStateCode to status 2.
If the DeletionStateCode of an object is set to 2, the object will be filtered out from all standard data views in the web application and is also not accessible through access via SDK web service calls.

Deletion service under CRM 2011
With CRM 2011 the deletion of objects will change from “soft delete” to “hard delete”. We now no longer use Deletion State Codes for marking objects. Instead objects will be deleted immediately. This helps to improve performance and also reduces complexity in case of filtered views or tables.

But in Crm 2011 now we have DeletionService Async Maintenance
To provide some context from CRM 4.0, the DeletionService performed physical data cleanup on records that had been logically deleted through the application by setting the DeletionStateCode = ‘2’.  This behavior no longer occurs in CRM 2011 – when records are deleted through the application, they are physically deleted from the database.  So, why the need for a DeletionService maintenance operation?
The database maintenance performed by the DeletionService operation focuses both on organization-wide cleanup and record-specific cleanup.  For the latter cleanup to be performed it’s important to note that during the initial delete action while records are removed from the entity tables, they are also inserted to the dbo.SubscriptionTrackingDeletedObject table.  This table provides the DeletionService with specific ObjectId’s that have been removed so that further cleanup can be performed asynchronously.

Now how to handle the requirement if customer want to recover the deleted record.
On click of delete button either Deactivate record on fire of java script or plugin or change custom id action and assign to some team.
later on write asynchronous plugin or work flow to clean the record from system after some period of time.