Thursday, 25 August 2011

CRM Deletion Service in CRM 4.0 and CRM 2011. Asynchronize

http://www.7388.info/index.php/article/silverlight/2011-07-18/19565.html
http://blogs.msdn.com/b/emeadcrmsupport/archive/2011/06/28/crm-deletion-service-in-crm-4-0-and-crm-2011.aspx

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
USE MSCRM_CONFIG
UPDATE dbo.ScaleGroupOrganizationMaintenanceJobs
SET NextRunTime = getdate()
WHERE OperationType = 14

--To check the time for the next job to run
USE MSCRM_CONFIG
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: http://code.msdn.microsoft.com/ScaleGroupJobEditor).

Possible values for the OperationType attribute can be found here:
http://msdn.microsoft.com/en-us/library/bb887932.aspx

No comments:

Post a Comment