删除角色:系统定制员产生的问题和解决方法

MSCRM3.0系统自带角色中,MS允许删除系统定制员角色,但是删除该角色后出现无法
客户化情况,因为创建实体的时候系统会自动为系统定制员角色赋予权限。系统定制员角色不存在所以就导致无法客户化。
解决方法一:
一、备份数据库
二、创建一个角色 角色名称:系统定制员 业务部门 选择 顶级部门
三、打开查询分析器 运行以下代码

注:以上方法请不要用于产品环境,不确保不会出现其他问题。

解决方法二:
一、备份数据库
二、打开查询分析器 运行以下代码

 1create function dbo.GetPrivilegeDepthMask(@isbasic bit@islocal bit@isdeep bit@isglobal bit@parentRoleId uniqueidentifier)returns int as
  2
  3begin 
  4
  5declare @mask int 
  6
  7select @mask = 0 
  8
  9 
 10
 11if (@isbasic <> 0
 12
 13begin 
 14
 15if (@parentRoleId is null
 16
 17begin 
 18
 19select @mask = 1 
 20
 21end 
 22
 23if (@parentRoleId is not null
 24
 25begin 
 26
 27select @mask = 0x00000010 
 28
 29end 
 30
 31end 
 32
 33if (@islocal <> 0
 34
 35begin 
 36
 37if (@parentRoleId is null)
 38
 39begin 
 40
 41select @mask = 2 
 42
 43end 
 44
 45if (@parentRoleId is not null
 46
 47begin 
 48
 49select @mask = 0x00000020 
 50
 51end 
 52
 53end 
 54
 55if (@isdeep <> 0
 56
 57begin 
 58
 59if (@parentRoleId is null
 60
 61begin 
 62
 63select @mask = 4 
 64
 65end 
 66
 67if (@parentRoleId is not null
 68
 69begin 
 70
 71select @mask = 0x00000040 
 72
 73end 
 74
 75end 
 76
 77if (@isglobal <> 0
 78
 79begin 
 80
 81if (@parentRoleId is null
 82
 83begin 
 84
 85select @mask = 8 
 86
 87end 
 88
 89if (@parentRoleId is not null
 90
 91begin 
 92
 93select @mask = 0x00000080 
 94
 95end 
 96
 97end 
 98
 99 
100
101return @mask 
102
103end 
104
105go 
106
107 
108
109declare @rootBiz uniqueidentifier 
110
111declare @rootId uniqueidentifier 
112
113declare @organizationid uniqueidentifier 
114
115 
116
117declare @roleTemplateId uniqueidentifier 
118
119select @roleTemplateId = '119F245C-3CC8-4B62-B31C-D1A046CED15D' 
120
121declare @roleTemplateName nvarchar(256
122
123select @roleTemplateName = Name from RoleTemplateBase where RoleTemplateId = @roleTemplateId 
124
125 
126
127declare @parentRoleId uniqueidentifier 
128
129select @parentRoleId = null 
130
131 
132
133declare @roleid uniqueidentifier 
134
135select @roleid = null 
136
137 
138
139select @rootBiz = BusinessUnitId from BusinessUnitBase where ParentBusinessUnitId is null 
140
141declare c cursor FORWARD_ONLY READ_ONLY for select businessunitid from dbo.GetSubsidiaryBusinesses(@rootBizorder by depth 
142
143open c 
144
145fetch next from c into @rootId 
146
147while (@@fetch_status = 0
148
149begin 
150
151-- Get ParentRoleId 
152
153select @parentRoleId = RoleId from RoleBase where BusinessUnitId = (select ParentBusinessUnitId from BusinessUnitBase where BusinessUnitId = @rootIdand RoleTemplateId = @roleTemplateId select @roleid = RoleId from RoleBase where BusinessUnitId = @rootId and RoleTemplateId = @roleTemplateId 
154
155if (@roleid is null
156
157begin 
158
159select @roleid = newid() 
160
161insert into RoleBase(RoleId, RoleTemplateId, OrganizationId, DeletionStateCode, Name, BusinessUnitId, CreatedOn, ModifiedOn, CreatedBy, ModifiedBy, ParentRoleId) values(@roleid@roleTemplateId@organizationid0@roleTemplateName@rootId, getutcdate(), getutcdate(), nullnull@parentRoleId
162
163end 
164
165delete from RolePrivileges where RoleId = @roleid 
166
167insert into RolePrivileges(RoleId, PrivilegeId, PrivilegeDepthMask) 
168
169select @roleid, rtp.PrivilegeId, dbo.GetPrivilegeDepthMask(rtp.IsBasic, rtp.IsLocal, rtp.IsDeep, rtp.IsGlobal, @parentRoleIdfrom RoleTemplatePrivileges rtp where rtp.RoleTemplateId = @roleTemplateId 
170
171fetch next from c into @rootId 
172
173select @roleid = null 
174
175end 
176
177close c 
178
179deallocate c

 

      Techsun(天正计算机服务限公司 techsun.com)致力微软商务解决方案及电子商务的研究与开发。Techsun作为微软CRM金牌认证合作伙伴,并且拥有中国区域2位微软CRM MVP(微软最有价值专家),代表了我们在微软CRM技术应用的深度及对客户提供方案实施能力的承诺。

     业务咨询或服务建议,请拔打全国免费服务热线:800-830-9740。

 

posted on 2010-08-04 16:31  Techsun  阅读(272)  评论(0编辑  收藏  举报

养护内衣 飞机模型 锌钢公路护栏 组合式阳台护栏 组合式护栏 珠片 PET珠片 连线珠片 双螺杆挤出机 高速自动成圈机 自动成圈机