如何在多对多相交表上添加CRM插件步骤? [英] How do I add a CRM plugin step on a Many-to-Many Intersect Table?

查看:186
本文介绍了如何在多对多相交表上添加CRM插件步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在商机和自定义实体之间创建了(多对多)关系。
CRM会使用称为 相交表的内置表自动断开关系。

I have created a (many-to-many) relationship between Opportunity and a custom entity. CRM automatically breaks the relationship with a built-in table known as an "Intersect table".

在插件中注册工具,我想在此特定表上添加创建/更新/删除消息。但是问题是它在那里不存在-甚至那里也没有多对多系统关系。

In the Plug-in Registeration Tool, I would like to add Create/Update/Delete messages on this particular table. But the problem is that it does not exist there - even many-to-many system relationships do no exist there.

人们可能会建议我按顺序手动断开关系显示在注册工具中。但是,有什么解决方案可以访问此内置表?

People might advise me to manually break the relationship in order to be shown in the registration tool. But is there any solution to access this built-in table?

推荐答案

不幸的是,答案是否定的。 CRM中涉及许多表/关系的范例是,它们可用于 Association Disassociation 请求,但不是用于创建更新删除请求。 (实际上,相交表上没有真正的 Update -只能建立新的关联( Create => Associate )或已解散( Delete => Disassociate )。 )

The answer unfortunately will be no. The paradigm in the CRM concerning many to many tables/relationships is that they are available for Association and Disassociation requests but not for Create, Update, or Delete requests. (In fact, there is no real Update on an intersection table - new associations are only either made (Create => Associate) or dissolved (Delete => Disassociate).)

您可以通过查看交集实体的 AttributeMetadata 来验证这一点,然后看到您实体中的所有属性的字段 ValidForUpdateAPI ValidForCreateAPI 都设置为false。这与常规实体不同,常规实体具有可用于更新和创建调用的有效属性。

You can verify this in a way by looking at the AttributeMetadata for your intersection entity, and you'll see that all the attributes in your entity have the fields ValidForUpdateAPI and ValidForCreateAPI set to false. This differs from regular entities, which have a mix of attributes that are valid for update and create calls.

为了解决您的问题,您的选择受到限制:

In order to solve your problem, your options are limited:

1)在 Association 消息中注册您的步骤。不幸的是,该消息无法过滤到特定的实体,因此您将不得不过滤通过此插件在CRM中提出的所有关联请求。 IPluginExecutionContext InputParameters 属性包中有一个名为 Relationship的属性,您可以使用它过滤掉想要的关系

1) Register your step against the Association message. This message, unfortunately, can't be filtered to particular entities, so you will have to filter all association requests made in the CRM through this plugin. The IPluginExecutionContext has a property called "Relationship" in the InputParameters property bag you can use to filter out the relationship you want to develop code for.

Relationship entityRelationship = 
    (Relationship)context.InputParameters["Relationship"];
if (entityRelationship.SchemaName = customIntersectTable.EntityLogicalName)
{
    EntityReference targetEntity =
        (EntityReference)context.InputParameters["Target"];
     EntityReferenceCollection relatedEntities = 
        (EntityReferenceCollection)context.InputParameters["RelatedEntities"];
    //do stuff
}

2)创建一个自定义相交实体,与机会和您的自定义实体有一对多关系(类似于 OpporunityProduct 之类的东西,它将机会与产品联系起来) 。这里的缺点是这种事情的GUI并不像简单的交集实体那样好用。

2) Make a custom intersect entity that has one to many relationships with Opportunity and your custom entity (similar to something like OpporunityProduct, which links opportunities with products). The downside here is that the GUI for this kind of thing isn't nearly as nice for this as it is for simple intersection entities.

Gonzalo Ruiz有一个与此主题相关的博客(a:N)上也在MSDN上添加title =触发插件/工作流。他几乎说了同样的话。

Gonzalo Ruiz has a blog on this topic on MSDN as well. He pretty much says the same thing.

这篇关于如何在多对多相交表上添加CRM插件步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆