Dynamics Crm:通过API创建连接实体 [英] Dynamics Crm: creating Connection entities via API

查看:178
本文介绍了Dynamics Crm:通过API创建连接实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,Dynamics CRM中的Connections提供了一种将事物链接在一起的通用方法。

So Connections in Dynamics CRM provide a general purpose way of linking things together.

在内部,Connections实体具有Record1Id属性和Record2Id属性。

Internally the Connections entity has a Record1Id attribute and a Record2Id attribute, among other things.

创建通过UI进行连接,CRM实际上是 在数据库的Connection表中创建两个条目,每个条目都允许您从原始记录或相关记录中搜索相关记录。

When you create a connection via the UI, CRM actually "creates two entries in the Connection table in the database. Each entry allows you to search for the related record from the originating record or the related record."

也就是说,如果您连接A和B,它将保存两行到(后台)表:

That is, if you connect A and B, it saves two rows to the (behind the scenes) table:


  • 其中一个具有Record1Id = A和Record2Id = B

  • ,其中一个Record1Id = B和Record2Id = A

这是为了使搜索连接更容易。如果您对连接进行高级查找,则只需单向搜索即可。

This is to make searching for connections easier. If you do an Advanced Find on connections, you only have to do the search 'one way round'.

我的问题是:

通过API创建连接(后期绑定)时,会发生以下情况:

When you create Connections via the API (late bound), which goes something like this:

Entity connection = new Entity("connection");
connection["record1id"] = new EntityReference("contact", someContactId);
connection["record1objecttypecode"] = new OptionSetValue(2);
connection["record1roleid"] = new EntityReference("connectionrole", someConnectionRoleId);
connection["record2id"] = new EntityReference("incident", someCaseId);
connection["record2objecttypecode"] = new OptionSetValue(122);
connection["record2roleid"] = new EntityReference("connectionrole", someOtherConnectionRoleId);
var newId = service.Create(connection);

...是否足以如上所述创建它们单向,然后在场景CRM将在两个方向上创建连接?

...还是需要在两个方向上手动创建它们? (通过保存两次并在record1id和record2id值之间交换,等等)

... is it sufficient to create them 'one way round' as above, and then behind the scenes CRM will create connections in both directions?
... or do you need to manually create them in both directions? (by saving twice and swapping round the record1id record2id values, etc)

或者,换句话说,CRM API for Connections封装了它实际上是两个后面的连接场景的功能,还是需要自己手动处理?

Or, in other words, does the CRM API for Connections encapsulate the 'its actually two connections behind the scenes' functionality, or do you need to manually handle that yourself?

推荐答案

您只需要创建一个连接记录。需要注意的一件事是,我认为您不需要像上面那样设置类型代码。仅在实体引用中设置逻辑名就足够了。这是SDK中的示例:

You just need to create one connection record. One thing to note is I don't think you need to set the typecodes as you are doing above. Just setting the logical names in the entity references should be enough. Here is the sample from the SDK:

Connection newConnection = new Connection
{
    Record1Id = new EntityReference(Account.EntityLogicalName,
        _accountId),
    Record1RoleId = new EntityReference(ConnectionRole.EntityLogicalName,
        _connectionRoleId),                             
    Record2RoleId = new EntityReference(ConnectionRole.EntityLogicalName,
        _connectionRoleId),                            
    Record2Id = new EntityReference(Contact.EntityLogicalName,
        _contactId)
};
_connectionId = _serviceProxy.Create(newConnection);

这篇关于Dynamics Crm:通过API创建连接实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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