Setting the Default Org for Dynamics CRM

If you work a lot with Dynamics 365/CRM On-premise systems with multiple organizations (business lines or DEV/TEST), sooner or later you will likely to run into some known issues with users running reports because their user account does not have a security role in their “default” CRM organization.

Essentially if a user was created first in “org1” and then in “org2”, their default org is still “org1”.  If “org1” is disabled or if the user is deactivated in “org1”, then when they run reports from “org2”, they will get an error.

A decent overview of the issue is detailed here

Despite the fact the link above is an older blog I know the issue persists to at least CRM 2013 and likely still exists in current versions.  Translation: Guess what I am dealing with this week?

This issue doesn’t seem to be a problem with Dynamics 365 Online.

The following are steps to set a particular organization to be the default org for all users.

WARNING: These steps are meant for educational and informational purposes only.  Make sure you have full backups of MSCRM_Config and your organizational databases.  Keep away from pets and small children.  Adult supervision required.  Do not try this at home.

If we run our Dynamics CRM Deployment Manager we see that we have 2 orgs;

DEVCRM and TEST.

multipleorgs1

The user “Jim Smith” has been added first to the “DEVCRM” organization.

jimmydevcrm

Jim Smith is also a user in the “TEST” organization.

jimmytestcrm

How can we tell which of these organizations is considered Jim Smith’s “Default Org”?

This blog article explains the process of determining which organizations is considered “default” for a particular user.

I have taken the SQL script provided by the blog author and modified it to be run by just defining the user name and setting one of the org database names.

declare @username varchar(100)
declare @crmuserid varchar(50)
declare @systemuserid varchar(50)
declare @orgid varchar(50)

set @username = 'CRMDEV\jim.smith'

USE TEST_MSCRM
Select @crmuserid = systemuserid from systemuserbase where domainname = @username

USE [MSCRM_CONFIG]
select @systemuserid = UserId from systemuserorganizations where CrmUserId = @crmuserid

USE [MSCRM_CONFIG]
select @orgid = defaultOrganizationId from SystemUser where id = @systemuserid

USE [MSCRM_CONFIG]
select @username as username, DatabaseName,UniqueName from organization where id = @orgid

 

Running this SQL script against either of your CRM organizational databases will determine the default org for the user.

In this case, we see that Jim’s default org is set to DEVCRM_MSCRM

jimmydefaultorg

Changing the Default Org

The following steps will change the default org for ALL users that have accounts in all existing organizations.

Another reminder to make a SQL backup of your MSCRM_Config and organization databases.

Note that no users can be using CRM at this time.

The first step is to DISABLE all orgs in your deployment.

disablebothorgs

The next step is to DELETE each of these orgs.

NOTE: They will not truly be deleted, the SQL databases will still exist.  They will be removed from the CRM deployment.

Delete DEVCRM

deleteorg

Delete TEST

deletetestorg

You will have an empty CRM deployment.

nororgs

The next step is to “Import Organization” and choose FIRST the organization that you want to be the “default” org for your users.  (In our example, the TEST org)

importnewDEFAULT

After, import the rest of the CRM orgs.

orgsreimported

After the orgs have been re-imported, the next step is determine Jim’s default organization, running the same SQL script as before:

jimTESTdefault

We see that Jim Smith’s default org is now set to TEST.

At any point you can revert to your original configuration by restoring in SQL the MSCRM_config and organization databases.

You will likely need to reset your IFD (Internet Facing Deployments) and possibly CRM for Outlook connections.

benfranklin

I hope this information helps you in understanding default organizations can be set.

Nick Doelman is a Microsoft Business Solutions MVP and is pretty excited that the Canadian Football season is about to start.  Go REDBLACKS!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s