declare @DeleteRowCount int
Select @DeleteRowCount = 2000
declare @DeletedAsyncRowsTable table (AsyncOperationId uniqueidentifier not null)
declare @continue int, @rowCount int
select @continue = 1
while (@continue = 1)
begin
begin tran
insert into @DeletedAsyncRowsTable(AsyncOperationId)
Select top (@DeleteRowCount) AsyncOperationId
from AsyncOperationBase
where OperationType in (1, 9, 12, 25, 27, 10) AND StateCode = 3 AND StatusCode in (30, 32)
Select @rowCount = 0
Select @rowCount = count(*) from @DeletedAsyncRowsTable
select @continue = case when @rowCount <= 0 then 0 else 1 end
if (@continue = 1)
begin
delete WorkflowLogBase from WorkflowLogBase W, @DeletedAsyncRowsTable d
where W.AsyncOperationId = d.AsyncOperationId
delete BulkDeleteFailureBase From BulkDeleteFailureBase B, @DeletedAsyncRowsTable d
where B.AsyncOperationId = d.AsyncOperationId
delete AsyncOperationBase From AsyncOperationBase A, @DeletedAsyncRowsTable d
where A.AsyncOperationId = d.AsyncOperationId
delete @DeletedAsyncRowsTable
end
commit
end
Select Count(*) from AsyncoperationBase Where OperationType = 10 AND StateCode = 3 AND StatusCode = 30
Wednesday, December 30, 2009
Wednesday, November 18, 2009
Removing Unwanted CRM E-mail Signature Graphics
Some e-mail signatures contain graphics that over time unnecessarily grow the ActivityMimeAttachment table. First run this script to identify how many of these attachments there are and their names:
select FileName, count (*) from activitymimeattachment group by FileName having count (*) >1000
Next, verify that you do not need that graphic file stored in CRM by running the following script and pasting the activityid into an exisiting e-mail activity and then open the attachments:
select top 10 * from activitymimeattachment where FileName = 'FILENAME.gif/jpg/png'
To delete those attachments run the following script:
declare @DeleteRowCount int
Select @DeleteRowCount = 2000
declare @DeletedActivityRowsTable table (ActivityMimeAttachmentId uniqueidentifier not null)
declare @continue int, @rowCount int
select @continue = 1
while (@continue = 1)
begin
begin tran
insert into @DeletedActivityRowsTable(ActivityMimeAttachmentId)
Select top (@DeleteRowCount) ActivityMimeAttachmentId
from ActivityMimeAttachment
--replace Filename and Filesize here
where filename in ('FILENAME.gif/jpg/png') and filesize = 'FileSize'
Select @rowCount = 0
Select @rowCount = count(*) from @DeletedActivityRowsTable
select @continue = case when @rowCount <= 0 then 0 else 1 end
if (@continue = 1)
begin
delete ActivityMimeAttachment from ActivityMimeAttachment AMA, @DeletedActivityRowsTable d
where AMA.ActivityMimeAttachmentId = d.ActivityMimeAttachmentId
delete @DeletedActivityRowsTable
end
commit
end
Once you identify the main e-mail graphics (most likely internal) you can set this script to run daily/weekly.
select FileName, count (*) from activitymimeattachment group by FileName having count (*) >1000
Next, verify that you do not need that graphic file stored in CRM by running the following script and pasting the activityid into an exisiting e-mail activity and then open the attachments:
select top 10 * from activitymimeattachment where FileName = 'FILENAME.gif/jpg/png'
To delete those attachments run the following script:
declare @DeleteRowCount int
Select @DeleteRowCount = 2000
declare @DeletedActivityRowsTable table (ActivityMimeAttachmentId uniqueidentifier not null)
declare @continue int, @rowCount int
select @continue = 1
while (@continue = 1)
begin
begin tran
insert into @DeletedActivityRowsTable(ActivityMimeAttachmentId)
Select top (@DeleteRowCount) ActivityMimeAttachmentId
from ActivityMimeAttachment
--replace Filename and Filesize here
where filename in ('FILENAME.gif/jpg/png') and filesize = 'FileSize'
Select @rowCount = 0
Select @rowCount = count(*) from @DeletedActivityRowsTable
select @continue = case when @rowCount <= 0 then 0 else 1 end
if (@continue = 1)
begin
delete ActivityMimeAttachment from ActivityMimeAttachment AMA, @DeletedActivityRowsTable d
where AMA.ActivityMimeAttachmentId = d.ActivityMimeAttachmentId
delete @DeletedActivityRowsTable
end
commit
end
Once you identify the main e-mail graphics (most likely internal) you can set this script to run daily/weekly.
CRM - E-mail Router Maintenence
The CRM e-mail router was designed to accept incoming e-mail that has been forwarded from CRM users inboxes and track those e-mails (w/tracking tokens) in CRM. If the e-mail does not contain a tracking token it will permanently delete that e-mail from the e-mail router’s inbox.
The e-mail router only discerns e-mails sent within the past 24 hours. On occasion the e-mail router is unable to process an e-mail and therefore does not process e-mails into CRM but rather remain in the router's inbox. This does not happen often, but when it does a back-log of e-mails begins to build up in the router’s inbox. These e-mails have a tracking token and need to be tracked in CRM and here is how to make that happen:
1. Log onto the server that the router is installed
2. Stop the Microsoft CRM email router service
3. Open C:\Program Files\Microsoft CRM Email\Service
4. Delete the file Microsoft.Crm.Tools.EmailAgent.SystemState.xml
5. Start the Microsoft CRM email router service
Once the service is restarted, the file Microsoft.Crm.Tools.EmailAgent.SystemState.xml will be recreated with no time stamp. The e-mails in the router's inbox will then be processed into CRM.
The e-mail router only discerns e-mails sent within the past 24 hours. On occasion the e-mail router is unable to process an e-mail and therefore does not process e-mails into CRM but rather remain in the router's inbox. This does not happen often, but when it does a back-log of e-mails begins to build up in the router’s inbox. These e-mails have a tracking token and need to be tracked in CRM and here is how to make that happen:
1. Log onto the server that the router is installed
2. Stop the Microsoft CRM email router service
3. Open C:\Program Files\Microsoft CRM Email\Service
4. Delete the file Microsoft.Crm.Tools.EmailAgent.SystemState.xml
5. Start the Microsoft CRM email router service
Once the service is restarted, the file Microsoft.Crm.Tools.EmailAgent.SystemState.xml will be recreated with no time stamp. The e-mails in the router's inbox will then be processed into CRM.
Tuesday, November 17, 2009
Deploying an MSCRM 4.0 Test Environment with production data
1. You will need the most recent backups of the MSCRM_CONFIG and Org_MSCRM databases from your production environment.
2. Install MSCRM on the application server as a new installation with the same Organization name as the production environment.
3. Restore both backups directly over the newly created databases. It is very important that you do not make any changes to the data at this point because your test application server is pointing to your production database.
4. Run the following script on the test database to unorphan database users:
exec sp_change_users_login 'report'
declare @usrname varchar(100), @command varchar(100)
declare Crs insensitive cursor for
select name as UserName from sysusers
where issqluser = 1 and (sid is not null and sid <> 0x0)
and suser_sname(sid) is null
order by name
for read only
open Crs
fetch next from Crs into @usrname
while @@fetch_status=0
begin
select @command=' sp_change_users_login ''auto_fix'', '''+@usrname+''' '
exec(@command)
fetch next from Crs into @usrname
end
close Crs
deallocate Crs
5. Log onto the test application server and disable the Org that was just created.
6. Highlight the Organization and click edit.
7. In the next screen make the appropriate changes and run through the rest of the wizard. This usually takes up to 10 minutes to complete.
8. Open the table [Server] on the MSCRM_CONFIG database and change the servers from the production names to the test names.
9. Open the table [DeploymentProperties] on the MSCRM_CONFIG database and change the 2 entries of the production servers to the test servers. Run the following script against the MSCRM_CONFIG database to ensure everything is pointing to the correct place:
SELECT ConnectionString, SrsUrl FROM Organization
10. Go back to the Deployment Manager and re-enable the test Organization.
11. Finally, the last change that needs to be made is to export the isv.config and sitemap from the test CRM environment and edit in Notepad++. Find and Replace all references of the production CRM to the test CRM. Save those files and import them into the Test environment.
2. Install MSCRM on the application server as a new installation with the same Organization name as the production environment.
3. Restore both backups directly over the newly created databases. It is very important that you do not make any changes to the data at this point because your test application server is pointing to your production database.
4. Run the following script on the test database to unorphan database users:
exec sp_change_users_login 'report'
declare @usrname varchar(100), @command varchar(100)
declare Crs insensitive cursor for
select name as UserName from sysusers
where issqluser = 1 and (sid is not null and sid <> 0x0)
and suser_sname(sid) is null
order by name
for read only
open Crs
fetch next from Crs into @usrname
while @@fetch_status=0
begin
select @command=' sp_change_users_login ''auto_fix'', '''+@usrname+''' '
exec(@command)
fetch next from Crs into @usrname
end
close Crs
deallocate Crs
5. Log onto the test application server and disable the Org that was just created.
6. Highlight the Organization and click edit.
7. In the next screen make the appropriate changes and run through the rest of the wizard. This usually takes up to 10 minutes to complete.
8. Open the table [Server] on the MSCRM_CONFIG database and change the servers from the production names to the test names.
9. Open the table [DeploymentProperties] on the MSCRM_CONFIG database and change the 2 entries of the production servers to the test servers. Run the following script against the MSCRM_CONFIG database to ensure everything is pointing to the correct place:
SELECT ConnectionString, SrsUrl FROM Organization
10. Go back to the Deployment Manager and re-enable the test Organization.
11. Finally, the last change that needs to be made is to export the isv.config and sitemap from the test CRM environment and edit in Notepad++. Find and Replace all references of the production CRM to the test CRM. Save those files and import them into the Test environment.
Subscribe to:
Posts (Atom)