Thursday, 25 August 2011

CRM Deletion Service in CRM 4.0 and CRM 2011. Asynchronize

All activities of the Deletion Service are based on table named ScaleGroupOrganizationMaintenanceJobs, which can be found in the MSCRM_CONFIG database.
You can use the following sample script to delete all records marked for deletion immediately. As direct database manipulation is not supported, this should be done only in test and not in productive environment.
--The time you set is UTC time so you need to minus 11 or 12 hours as NZ time is UTC + 12:00
UPDATE dbo.ScaleGroupOrganizationMaintenanceJobs
SET NextRunTime = getdate()
WHERE OperationType = 14

--To check the time for the next job to run
select NextRunTime
from dbo.ScaleGroupOrganizationMaintenanceJobs
where OperationType = 14

By default the SQL Server agent will trigger the job MSCRM_CONFIG.HardDelete every hour. This job will execute the stored procedure p_HardDelete, which will perform the deletion itself.

If the SQL Server Agent is not running, you have to wait on the Deletion Service itself. By default, the frequency of the Deletion Service job execution is set to once a day.

p_HardDelete is different from the Deletion Service. p_HardDelete seems to only delete internal Entities' record.

You can use the Scale Group Job Editor tool to change the execution frequency of the Deletion Service (Download here:

Possible values for the OperationType attribute can be found here:

No comments:

Post a Comment