如何在 CRM 365 中共享记录
How to share record in CRM 365
我想在满足几个条件时分享我的记录,我可以用插件实现吗?我有我想分享的请求转移记录,所以当提交请求转移状态时,我将在我的请求转移字段中将我从仓库获得的记录分享给用户。我可以用插件做到这一点吗?
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
if(context.MessageName.ToUpper() == "UPDATE")
{
int requestStatus = transferImage.GetAttributeValue<OptionSetValue>("mjt_request_status").Value;
if(requestStatus == 2)
{
EntityReference warehouse = transferImage.GetAttributeValue<EntityReference>("mjt_request_to ");
ColumnSet columnSet = new ColumnSet(true);
var warehouses = service.Retrieve("msdyn_warehouse ", warehouse.Id, columnSet);
if (warehouses.Attributes.ContainsKey("mjt_administrator"))
{
adminstrator = warehouses.GetAttributeValue<EntityReference>("mjt_administrator");
}
if(adminstrator != null)
{
}
}
}
}
我的代码刚刚结束,我从转移请求中获取管理员,然后我不知道如何将请求共享给我的用户。
您必须使用 GrantAccessRequest
才能执行此操作。
// Grant the user read access to the record.
var grantAccessRequest1 = new GrantAccessRequest
{
PrincipalAccess = new PrincipalAccess
{
AccessMask = AccessRights.ReadAccess,
Principal = adminstrator
},
Target = transferReference
};
serviceProxy.Execute(grantAccessRequest1);
我想在满足几个条件时分享我的记录,我可以用插件实现吗?我有我想分享的请求转移记录,所以当提交请求转移状态时,我将在我的请求转移字段中将我从仓库获得的记录分享给用户。我可以用插件做到这一点吗?
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
if(context.MessageName.ToUpper() == "UPDATE")
{
int requestStatus = transferImage.GetAttributeValue<OptionSetValue>("mjt_request_status").Value;
if(requestStatus == 2)
{
EntityReference warehouse = transferImage.GetAttributeValue<EntityReference>("mjt_request_to ");
ColumnSet columnSet = new ColumnSet(true);
var warehouses = service.Retrieve("msdyn_warehouse ", warehouse.Id, columnSet);
if (warehouses.Attributes.ContainsKey("mjt_administrator"))
{
adminstrator = warehouses.GetAttributeValue<EntityReference>("mjt_administrator");
}
if(adminstrator != null)
{
}
}
}
}
我的代码刚刚结束,我从转移请求中获取管理员,然后我不知道如何将请求共享给我的用户。
您必须使用 GrantAccessRequest
才能执行此操作。
// Grant the user read access to the record.
var grantAccessRequest1 = new GrantAccessRequest
{
PrincipalAccess = new PrincipalAccess
{
AccessMask = AccessRights.ReadAccess,
Principal = adminstrator
},
Target = transferReference
};
serviceProxy.Execute(grantAccessRequest1);