默认情况下显示特定用户角色的特定仪表板 [英] Display a specific dashboard by default for a specific user role

查看:99
本文介绍了默认情况下显示特定用户角色的特定仪表板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在线配置Dynamics CRM 2011,以便默认情况下针对特定用户角色显示特定仪表板。是否可以通过某些设置或使用插件或JavaScript编写自定义代码来实现?

I want to configure Dynamics CRM 2011 online so that it shows a specific dashboard by default for a specific user role. Is this possible through some setting or by writing customization code using a plugin or javascript?

例如,如果首席执行官约翰(John)登陆-他应该看到年收入仪表板,如果销售人员登录后,他们将看到销售线索仪表板。
仪表板是公共仪表板,而不是个人仪表板。

For example if John the CEO logs in - he should see the annual revenue dashboard, if a sales person logs in they see the leads dashboard. The dashboards are public dashboards and not personal dashboards.

推荐答案

如果您使用的是本地版本,则可能最快的方法是访问数据库表 UserSettingsBase 并将 DefaultDashboardId 列更新为您的仪表板的GUID希望每个用户都有。 (编辑-刚刚意识到您正在使用CRM Online,因此不适用。)

If you have the on-premise version, probably the fastest way to do this is to access the database table UserSettingsBase and update the DefaultDashboardId column to the guid of the dashboard you want each user to have. (Edit - just realized you're using CRM Online, so this is not applicable.)

您可以通过实例化<$ c $在API框架中完成相同的操作c>每个用户的UserSettings 实体,找到每个用户的相应 roleid ,并更新 DefaultDashboardID UserSettings 实体的属性。下面是一个示例。

You can accomplish the same in the API framework by instantiating the UserSettings entity for each user, finding each user's appropriate roleid, and updating the DefaultDashboardID property of the UserSettings entity. An example is below.

using (OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(new Uri("Your CRM Server"), null, null, null))
{
    _serviceProxy.EnableProxyTypes();
    using (OrganizationServiceContext osc = new OrganizationServiceContext(_serviceProxy))
    {
        var usersSettings = from u in osc.CreateQuery<SystemUser>()
                            join ur in osc.CreateQuery<SystemUserRoles>() on u.SystemUserId.Value equals ur.SystemUserId.Value
                            join r in osc.CreateQuery<Role>() on ur.RoleId.Value equals r.RoleId.Value
                            select new
                            {
                                id = u.SystemUserId.Value
                                , roleName = r.Name
                            };

        foreach (var users in usersSettings)
        {
            UserSettings us = new UserSettings();
            us.SystemUserId = users.id;
            switch (users.roleName)
            {
                case "CEO":
                    us.DefaultDashboardId = Guid.Parse("2E3D0841-FA6D-DF11-986C-00155D2E3002"); //the appropriate dashboardid
                    break;
                //case "Sales Person"
                //case "..."
                //default: ...
            }
            _serviceProxy.Update(us);
        }
    }
}

这篇关于默认情况下显示特定用户角色的特定仪表板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆