Sometimes, there are problems with this sync and the user can’t go offline. To fix this error, you might clean up the tables with the synced information. This means, that the client seems to be a “new” client to CRM and will be fully resynced on the next offline-sync.
Each client, which is registered with the CRM outlook client (online and offline), gets a subscription ID in the subscription table in the CRM-database.
Each time the client goes offline with the CRM outlook client, the data is synced to the client, but also saved with the synced version in the CRM-database.
Be aware, that this script is not supported by Microsoft itself. Take a backup of your database, before you execute the script.
The script is based on the following sql-script from Microsoft.
The Microsoft-Script only supports CRM 2011, this script supports CRM 2016 and Dynamics 365.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
Declare @userName varchar(60), @syncId uniqueidentifier, @SQL nvarchar(MAX), @execute bit --To run the deletions set this to 1, if it is 0 it will only print the statements SET @execute = 0 -- Getting all entires, where the last sync date is older than a specific daycount or it was never synced. -- We only process subscriptions, that are connected to offline clients DECLARE CRMSync_cursor CURSOR FOR SELECT SubscriptionId, SystemUser.FullName from subscription left join SystemUser on SystemUser.SystemUserId = Subscription.SystemUserId where SystemUser.Fullname = 'Mittermair, Michael' --where (LastSyncStartedOn < GetDate()-90 or LastSyncStartedOn is NULL) and SyncEntryTableName ='SubscriptionSyncEntryOfflineBase' OPEN CRMSync_cursor FETCH NEXT FROM CRMSync_cursor INTO @syncId, @userName WHILE @@Fetch_Status = 0 BEGIN PRINT 'Processing User ' + @userName SET @SQL = 'delete from SubscriptionManuallyTrackedObject where SubscriptionId = ''' + CAST(@syncId as varchar(50)) + ''';' + 'delete from SubscriptionClients where SubscriptionId = ''' + CAST(@syncId as varchar(50)) + ''';' + 'delete from SubscriptionSyncInfo where SubscriptionId = ''' + CAST(@syncId as varchar(50)) + ''';' + 'delete from SubscriptionStatisticsOfflineBase where SubscriptionId = ''' + CAST(@syncId as varchar(50)) + ''';' + 'delete from SubscriptionSyncEntryOfflineBase where SubscriptionId = ''' + CAST(@syncId as varchar(50)) + ''';' + 'delete from subscription where subscriptionId = ''' + CAST(@syncId as varchar(50)) + '''' IF @execute=1 EXEC sp_executesql @SQL IF @execute=0 PRINT @SQL FETCH NEXT FROM CRMSync_cursor INTO @syncId, @userName END CLOSE CRMSync_cursor DEALLOCATE CRMSync_cursor |
Update:
Some of you might still use the CRM Client in Outlook (also called Dynamics 365 for Outlook). Since the mid of 2017, Microsoft set this product as deprecated https://blogs.msdn.microsoft.com/crm/2017/08/08/deprecation-of-dynamics-365-for-outlook/ .