CRM升级之后,用户的自定义配置都变了。例如登录默认是日历,升级之后变成了Dashboard,所以需要修复。
刚开始我修改了用户模版,查看sql才发现,原来这些模版就是保存在users表中的,使用特殊的标识区别而已。所以才有了查有效用户的时候需要增加这几个标识:
SELECT user_userid from users where COALESCE(user_disabled, N'') = N'' AND ( User_IsTemplate = N'N' OR User_IsTemplate is NULL ) and user_deleted is null
用户表中,并没有记录用户创建的时选的是那个模版,我即使修改了模版里面的参数,重启了iis,刷新了原数据都没有改变用户的配置。所以只能自己往配置表里面插入记录了,逐个用户修改的话,太浪费时间。于是就有了下面的存储过程:[之所以要使用游标,我相信你做SageCRM话就懂得]
-- ============================================= -- Author: CTL Novus -- Create date: 2012-04-27 -- Description: 统一用户的配置 -- CheckUset 'Nset_LoginTo', 'calendar' -- CheckUset 'PreferredCssTheme', 'default' -- CheckUset 'NSet_DecimalPlaces', '0' -- CheckUset 'NSet_WeekStartDay', '1' -- ============================================= CREATE PROCEDURE CheckUset @key varchar(100), @value varchar(100) AS BEGIN update usersettings set uset_value = @value where uset_key = @key declare CreateWorkflow scroll cursor for SELECT user_userid from users where COALESCE(user_disabled, N'') = N'' AND ( User_IsTemplate = N'N' OR User_IsTemplate is NULL ) and user_deleted is null and user_userid not in (select uset_userid from usersettings where uset_key = @key) for UPDATE declare @user_userid INT open CreateWorkflow fetch from CreateWorkflow into @user_userid while @@fetch_status = 0 begin declare @usetid INT EXEC @usetid = eware_get_identity_id 'usersettings' insert into usersettings (uset_settingid,uset_userid,uset_key,uset_value) select @usetid,@user_userid,@key,@value fetch from CreateWorkflow into @user_userid end close CreateWorkflow deallocate CreateWorkflow END GO