1

我正在(自定义实体)的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”。

在此处输入图像描述

我不知道这个插件有什么问题。请帮忙。

4

1 回答 1

0

我已经解决了这个问题。我已经在更新消息中注册了这个插件,然后改变了RegisterFile.crmregister

MessageName="Disassociate"PrimaryEntityName=""

还更改了我的插件类的默认构造函数。

base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(10, "Disassociate", "", new Action<LocalPluginContext>(ExecutePreValidateProjectUpdate)));

希望这会帮助面临同样问题的人。

于 2013-06-28T07:31:13.317 回答