我正在Disassociate
Project
消息上创建一个插件(自定义实体);与User
实体具有N:N关系。它不起作用。这是代码。
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”。
我不知道这个插件有什么问题。请帮助。
答案 0 :(得分:0)
我已经解决了这个问题。
我在更新消息中注册了此插件,然后更改了RegisterFile.crmregister
MessageName="Disassociate"
和PrimaryEntityName=""
还更改了我的插件类的默认构造函数。
base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(10, "Disassociate", "", new Action<LocalPluginContext>(ExecutePreValidateProjectUpdate)));
希望这能帮助遇到同样问题的人。