4

我有两个系统实体:invoice 和 invicedetail。

在系统中存在关联 1:N - invoice_details(父:invoice,子:invoicedetail)。

我转到发票详细信息,然后转到产品部分(invoicedetail)并添加新产品。现在这个产品和发票是关联的,但我的插件没有触发;/

我在 associate 上注册了我的插件(插件注册工具中父子实体为空,执行为 POST-Operation)。

代码:

if(context.Message == "Associate")
{
    //but plugin not go here - it's not trigger on associate ;/
    if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference)
    {
        entityRef = (EntityReference)context.InputParameters["Target"];
        entity = service.Retrieve("invoice", entityRef.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet("invoiceid", "numberOfSomething"));
    }
    else
    {
        throw new Exception("excep");
    }
}
4

1 回答 1

2

我相信 associate 用于多对多。尝试在更新和创建 invoicedetail 时注册您的插件。您可能希望将过滤属性添加到更新中,以便仅在 invoicedetail 上的发票查找更改时触发。然后添加一个检查以仅在设置发票查找时执行您的逻辑。

于 2014-01-27T08:52:22.760 回答