Monday, March 21, 2011

Steps to Add Deployment Administrator in MSCRM 4.0 from Database


Hello friends,

After a long busy schedule, today I want to share my one of the recent experience when I was caught in a problem which was arise by my small mistake J and then I managed to overcome to the solution.

Recently we needed import one of our CRM organizations from one deployment to other but due to some technical reasons the import got failed. Due to that failure before restarting import again, I needed to remove all the false entries which got created in MSCRM_CONFIG database during the failed import action. Within few minutes I managed to remove all the referential entries from all the tables related to the failed to import organization. 

But later on when I opened Deployment Manager, it did not allowed me to open it and responded me with below error
“Only the administrators are able to use deployment manager. you are not a deployment administrator.”
and later on I found that during the deletion of the false entries, by mistake all the entries related to deployment managers also got deleted.

After searching for couple of hours I managed to add Deployment Administrator from database and I want to share you the steps I followed to achieve the same.

Step 1: Get "systemuserid" for the user whom you want as a "Deployment Administrator" from CRM Database
Query: 
select systemuserid,fullname from systemuser where fullname like '%prathmesh%'

Step 2: Open SQL Server Management Studio and fire below query against MSCRM_CONFIG database
Query: 
SELECT Id, UserId
FROM SystemUserOrganizations
WHERE CrmUserId = <<systemuserid>> --Replace <> by the systemuserid got from step 1

Step 3: Fire Below query to get Administrator Security Role Id
Query:
SELECT Id FROM SecurityRole WHERE name = 'Administrator'

Step 4: Fire below query to Insert a record in SystemUserRoles table of MSCRM_CONFIG database
Query:
INSERT INTO SystemUserRoles
(
     [Id]
     ,[SecurityRoleId]
     ,[SystemUserId]
     ,[IsDeleted]
)
VALUES
(
     NEWID(), -- new Guid
     ,<<SecurityRoleId>>  --Replace "Id" Guid found from Step 3
     ,<<UserId>> --replace "UserId" Guid found from step 2
     ,0
)

Step 5: Add Name to SystemUser table using below query
Query:
UPDATE SystemUser
SET name =  <<mydomain\username>>  -- User's domain name\username
WHERE Id = <<UserId>>  -- Replace "UserId" Guid found from step 2


Hope this post helps you jump out of a situation in which I was caught… J

Feel free to post the query in case you need help for Dynamics CRM and this post.

Monday, November 29, 2010

ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.

Hi..

Recently I came across one wierd Error found by one of my QA friend after we imported a new CRM 4.0 organization into our development environment. The error stated something like below (Error can be tracked in the trace log files. Check out this link to find out how to enable Tracing in CRM 4.0)

"System.InvalidOperationException: ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized."


We were facing this error on all the ISV aspx pages embedded into CRM and that too was user specific i.e. for some users these ISV pages worked fine but others were facing the above error.

After loads of digging and googling around the web, i came across this link which provided the solution but this was not the case for our error.

Solution : 
       The Solution was really very simple after we found it... The issue which we were facing was due to missing Default Organization for some of the users. We just updated the Default Organization for those users and the system go up and running.

Database: MSCRM_CONFIG
Table : Organization
Query : Select Id, UniqueName From Organization
              Get the Id from the above query result (In case of Multi-Tenancy, take the id of the organization which you want as default for the particular user)


Database: MSCRM_CONFIG
Table : SystemUser
Query : Update SystemUser
              Set DefaultOrganizaionId = <>
              Where Id = <>

Updating the DefaultOrganizationIds for the users will fix the above error and you are good to go to your boss and boast of your achievement !!! J

Hope you find this solution useful. Feel free to post the query in case you need help for Dynamics CRM and this post. J

Tuesday, October 12, 2010

Error message when you export or delete entities in Microsoft Dynamics CRM 4.0:
"An unhandled exception occurred during the execution of the current web request"


Hi,


Recently one of my friend faced a weird type of error while exporting the customization. Error was something like

"An unhandled exception occurred during the execution of the current web request"

After searching for the error on the web... I encountered the link of Microsoft Knowledge Base article for the issue and solution to it. 
Find the URL for the same: http://support.microsoft.com/kb/947096

The common root cause for this issue is:
  • An entity form has an attribute that does not exist.
  • A primary entity of a relationship was missing during the previous import and because of which the relationship lookup attribute on the secondary entity form became orphan.
Solution:
1.    Firstly you need to find out the entity for which the error is arising. (In case you are using Export All Customizations). 
After finding the Entity you need to find out the culprit attribute on that entity form which is orphan. To find out the same follow appropriate method as given in the Microsoft KB link which I provided above or for your faster reference find the same below:
 Note The error message in the platform trace file does not display the exact attribute that causes the problem.
2.    Open the Form editor, and then find the attribute that causes the problem. To do this, use one of the following methods:
    • Look for an attribute that is missing a label.
    • Look for an attribute the properties of which have only the Name value and do not have the Display Name value or the Description value.
    • Create a new record for the entity that you found, and then find the attribute that causes the problem.
3.    Create a temporary attribute that uses the same name as the attribute in the entity form.
4.    If the attribute is not required for the deployment, follow these steps:
a.    Delete the attribute from the entity form.
b.    Publish the entity.
c.    Delete the temporary attribute.

Please feel free to post any queries/comments you have...


Thanks. J


Tuesday, September 28, 2010

CRM Migration Error :
Microsoft.Crm.CrmException: Found no feature for Organization with Id

Hello Everyone,

Today while migrating CRM 4.0 to CRM 2011. I found very interesting issue. The Error which got caught in the Log was something like
Microsoft.Crm.CrmException: Found no feature for Organization with Id
After searching intensely, I found the root cause for the above error faced during Migration.

Note: This error will come only if your Migration has been failed once before due to some other reason.

Solution:
     The root cause for this error is the records for the failed Organization which gets inserted in the below tables of MSCRM_CONFIG database.

  • OrganizationProperties
  • SystemUserOrganizations
  • OrganizationFeatureMap
  • Organization

Delete all the records having references for the Failed Organization from these tables and then again start your migration process.

Yipeee.... After this you will get rid of the above error.... J

Feel free to post your queries/comments if any regarding the CRM Migration.

Thanks... J