我正在(自定义实体)的Disassociate
消息上创建一个插件;与实体Project
有 N:N 关系。User
它不工作。这是代码。
IOrganizationService service = localContext.OrganizationService;
IPluginExecutionContext context = localContext.PluginExecutionContext;
// Get Primary Entity
EntityReference target = (EntityReference)context.InputParameters["Target"];
if (target.LogicalName == "new_project" || target.LogicalName == "systemuser")
{
Relationship relationShip = (Relationship)context.InputParameters["Relationship"];
// Get Related Entities
EntityReferenceCollection relatedentities = (EntityReferenceCollection)context.InputParameters["RelatedEntities"];
foreach (EntityReference rel in relatedentities)
{
// Check Related Entity Logical & Schema name
if (rel.LogicalName == "new_project" && relationShip.SchemaName == "new_systemuser_new_project")
{
Entity user = service.Retrieve("systemuser", target.Id, new ColumnSet(true));
Entity project = service.Retrieve("new_project", rel.Id, new ColumnSet(true));
// Grant access
RevokeAccessRequest revokeAccessRequest = new RevokeAccessRequest
{
Revokee=target,
Target = rel
};
service.Execute(revokeAccessRequest);
}
}
}
但我无法使用插件注册工具调试此插件。它返回消息“App Domain Unloaded”。
我不知道这个插件有什么问题。请帮忙。