あなたはオンプレミス版を持っている場合は、おそらくこれを行うための最速の方法は、データベーステーブルUserSettingsBase
にアクセスし、各ユーザーが持ちたいダッシュボードのGUIDにDefaultDashboardId
列を更新することです。
UserSettings
エンティティを各ユーザーにインスタンシエートし、各ユーザーに適切なroleid
を見つけて、更新することができます。 DefaultDashboardID
UserSettings
エンティティのプロパティ。以下に例を示します。
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);
}
}
}