Donnerstag, 15. Januar 2009

Change default Organization in CRM 4.0

Here's a pretty useful script to set the default organization for a certain user. It will take the org that's configured as the default one in the deployment manager. Just replace "domain/username" with the desired user.

update mscrm_config.dbo.systemuser set mscrm_config.dbo.systemuser.defaultorganizationid =

(select sub.organizationid from systemuserbase sub,

mscrm_config.dbo.systemuserorganizations csuo

where sub.systemuserid = csuo.crmuserid and

csuo.userid = mscrm_config.dbo.systemuser.id)

where 1 =

(select count(*) from systemuserbase sub,

mscrm_config.dbo.systemuserorganizations csuo

where sub.systemuserid = csuo.crmuserid and

csuo.userid = mscrm_config.dbo.systemuser.id and
sub.domainname = 'domain\username')