CRM 2011现场安全 - 数据所有者

时间:2014-04-14 20:13:40

标签: crm microsoft-dynamics

我有一个带安全字段启用的自定义字段我也配置安全配置文件以允许管理员查看/更新此字段,但我还需要允许实体字段的所有者查看/更新此字段。 在我的情况下,在帐户&联系实体。

我尝试了几个插件,在我的搜索中发现它我不知道如何让它工作:

public void ShareSecureFieldWithOwner(Entity record)
{
// Any method that helps you find the AttributeMetadata Id
var attributeId = FindSecuredAttribute();

if (attributeId != Guid.Empty)
{
    var userAccess = new PrincipalObjectAttributeAccess
                         {
                             AttributeId = attributeId,
                             ObjectId = record.ToEntityReference(),
                             PrincipalId = record.OwnerId,
                             UpdateAccess = true,
                             ReadAccess = true
                         };

    context.AddObject(userAccess);
    context.SaveChanges();
}
}

提前致谢&感谢您的支持。

1 个答案:

答案 0 :(得分:0)

我认为邮件问题是 var attributeId = FindSecuredAttribute(); 行。你有没有写过那种方法?