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

Code
UPDATE RoleBase SET RoleTemplateId = (SELECT RoleTemplateId FROM RoleTemplateBase WHERE Name = '系统定制员')
WHERE RoleTemplateId IS NULL AND Name = '系统定制员'
注:以上方法请不要用于产品环境,不确保不会出现其他问题。
解决方法二:
一、备份数据库
二、打开查询分析器 运行以下代码

Code
1
create function dbo.GetPrivilegeDepthMask(@isbasic bit, @islocal bit, @isdeep bit, @isglobal bit, @parentRoleId uniqueidentifier)returns int as
2
3
begin
4
5
declare @mask int
6
7
select @mask = 0
8
9
10
11
if (@isbasic <> 0)
12
13
begin
14
15
if (@parentRoleId is null)
16
17
begin
18
19
select @mask = 1
20
21
end
22
23
if (@parentRoleId is not null)
24
25
begin
26
27
select @mask = 0x00000010
28
29
end
30
31
end
32
33
if (@islocal <> 0)
34
35
begin
36
37
if (@parentRoleId is null)
38
39
begin
40
41
select @mask = 2
42
43
end
44
45
if (@parentRoleId is not null)
46
47
begin
48
49
select @mask = 0x00000020
50
51
end
52
53
end
54
55
if (@isdeep <> 0)
56
57
begin
58
59
if (@parentRoleId is null)
60
61
begin
62
63
select @mask = 4
64
65
end
66
67
if (@parentRoleId is not null)
68
69
begin
70
71
select @mask = 0x00000040
72
73
end
74
75
end
76
77
if (@isglobal <> 0)
78
79
begin
80
81
if (@parentRoleId is null)
82
83
begin
84
85
select @mask = 8
86
87
end
88
89
if (@parentRoleId is not null)
90
91
begin
92
93
select @mask = 0x00000080
94
95
end
96
97
end
98
99
100
101
return @mask
102
103
end
104
105
go
106
107
108
109
declare @rootBiz uniqueidentifier
110
111
declare @rootId uniqueidentifier
112
113
declare @organizationid uniqueidentifier
114
115
116
117
declare @roleTemplateId uniqueidentifier
118
119
select @roleTemplateId = '119F245C-3CC8-4B62-B31C-D1A046CED15D'
120
121
declare @roleTemplateName nvarchar(256)
122
123
select @roleTemplateName = Name from RoleTemplateBase where RoleTemplateId = @roleTemplateId
124
125
126
127
declare @parentRoleId uniqueidentifier
128
129
select @parentRoleId = null
130
131
132
133
declare @roleid uniqueidentifier
134
135
select @roleid = null
136
137
138
139
select @rootBiz = BusinessUnitId from BusinessUnitBase where ParentBusinessUnitId is null
140
141
declare c cursor FORWARD_ONLY READ_ONLY for select businessunitid from dbo.GetSubsidiaryBusinesses(@rootBiz) order by depth
142
143
open c
144
145
fetch next from c into @rootId
146
147
while (@@fetch_status = 0)
148
149
begin
150
151
-- Get ParentRoleId
152
153
select @parentRoleId = RoleId from RoleBase where BusinessUnitId = (select ParentBusinessUnitId from BusinessUnitBase where BusinessUnitId = @rootId) and RoleTemplateId = @roleTemplateId select @roleid = RoleId from RoleBase where BusinessUnitId = @rootId and RoleTemplateId = @roleTemplateId
154
155
if (@roleid is null)
156
157
begin
158
159
select @roleid = newid()
160
161
insert into RoleBase(RoleId, RoleTemplateId, OrganizationId, DeletionStateCode, Name, BusinessUnitId, CreatedOn, ModifiedOn, CreatedBy, ModifiedBy, ParentRoleId) values(@roleid, @roleTemplateId, @organizationid, 0, @roleTemplateName, @rootId, getutcdate(), getutcdate(), null, null, @parentRoleId)
162
163
end
164
165
delete from RolePrivileges where RoleId = @roleid
166
167
insert into RolePrivileges(RoleId, PrivilegeId, PrivilegeDepthMask)
168
169
select @roleid, rtp.PrivilegeId, dbo.GetPrivilegeDepthMask(rtp.IsBasic, rtp.IsLocal, rtp.IsDeep, rtp.IsGlobal, @parentRoleId) from RoleTemplatePrivileges rtp where rtp.RoleTemplateId = @roleTemplateId
170
171
fetch next from c into @rootId
172
173
select @roleid = null
174
175
end
176
177
close c
178
179
deallocate c
客户化情况,因为创建实体的时候系统会自动为系统定制员角色赋予权限。系统定制员角色不存在所以就导致无法客户化。
解决方法一:
一、备份数据库
二、创建一个角色 角色名称:系统定制员 业务部门 选择 顶级部门
三、打开查询分析器 运行以下代码
UPDATE RoleBase SET RoleTemplateId = (SELECT RoleTemplateId FROM RoleTemplateBase WHERE Name = '系统定制员')
WHERE RoleTemplateId IS NULL AND Name = '系统定制员'解决方法二:
一、备份数据库
二、打开查询分析器 运行以下代码
1
create function dbo.GetPrivilegeDepthMask(@isbasic bit, @islocal bit, @isdeep bit, @isglobal bit, @parentRoleId uniqueidentifier)returns int as2

3
begin 4

5
declare @mask int 6

7
select @mask = 0 8

9
10

11
if (@isbasic <> 0) 12

13
begin 14

15
if (@parentRoleId is null) 16

17
begin 18

19
select @mask = 1 20

21
end 22

23
if (@parentRoleId is not null) 24

25
begin 26

27
select @mask = 0x00000010 28

29
end 30

31
end 32

33
if (@islocal <> 0) 34

35
begin 36

37
if (@parentRoleId is null)38

39
begin 40

41
select @mask = 2 42

43
end 44

45
if (@parentRoleId is not null) 46

47
begin 48

49
select @mask = 0x00000020 50

51
end 52

53
end 54

55
if (@isdeep <> 0) 56

57
begin 58

59
if (@parentRoleId is null) 60

61
begin 62

63
select @mask = 4 64

65
end 66

67
if (@parentRoleId is not null) 68

69
begin 70

71
select @mask = 0x00000040 72

73
end 74

75
end 76

77
if (@isglobal <> 0) 78

79
begin 80

81
if (@parentRoleId is null) 82

83
begin 84

85
select @mask = 8 86

87
end 88

89
if (@parentRoleId is not null) 90

91
begin 92

93
select @mask = 0x00000080 94

95
end 96

97
end 98

99
100

101
return @mask 102

103
end 104

105
go 106

107
108

109
declare @rootBiz uniqueidentifier 110

111
declare @rootId uniqueidentifier 112

113
declare @organizationid uniqueidentifier 114

115
116

117
declare @roleTemplateId uniqueidentifier 118

119
select @roleTemplateId = '119F245C-3CC8-4B62-B31C-D1A046CED15D' 120

121
declare @roleTemplateName nvarchar(256) 122

123
select @roleTemplateName = Name from RoleTemplateBase where RoleTemplateId = @roleTemplateId 124

125
126

127
declare @parentRoleId uniqueidentifier 128

129
select @parentRoleId = null 130

131
132

133
declare @roleid uniqueidentifier 134

135
select @roleid = null 136

137
138

139
select @rootBiz = BusinessUnitId from BusinessUnitBase where ParentBusinessUnitId is null 140

141
declare c cursor FORWARD_ONLY READ_ONLY for select businessunitid from dbo.GetSubsidiaryBusinesses(@rootBiz) order by depth 142

143
open c 144

145
fetch next from c into @rootId 146

147
while (@@fetch_status = 0) 148

149
begin 150

151
-- Get ParentRoleId 152

153
select @parentRoleId = RoleId from RoleBase where BusinessUnitId = (select ParentBusinessUnitId from BusinessUnitBase where BusinessUnitId = @rootId) and RoleTemplateId = @roleTemplateId select @roleid = RoleId from RoleBase where BusinessUnitId = @rootId and RoleTemplateId = @roleTemplateId 154

155
if (@roleid is null) 156

157
begin 158

159
select @roleid = newid() 160

161
insert into RoleBase(RoleId, RoleTemplateId, OrganizationId, DeletionStateCode, Name, BusinessUnitId, CreatedOn, ModifiedOn, CreatedBy, ModifiedBy, ParentRoleId) values(@roleid, @roleTemplateId, @organizationid, 0, @roleTemplateName, @rootId, getutcdate(), getutcdate(), null, null, @parentRoleId) 162

163
end 164

165
delete from RolePrivileges where RoleId = @roleid 166

167
insert into RolePrivileges(RoleId, PrivilegeId, PrivilegeDepthMask) 168

169
select @roleid, rtp.PrivilegeId, dbo.GetPrivilegeDepthMask(rtp.IsBasic, rtp.IsLocal, rtp.IsDeep, rtp.IsGlobal, @parentRoleId) from RoleTemplatePrivileges rtp where rtp.RoleTemplateId = @roleTemplateId 170

171
fetch next from c into @rootId 172

173
select @roleid = null 174

175
end 176

177
close c 178

179
deallocate c
浙公网安备 33010602011771号