简体   繁体   English

如何在Microsoft Dynamics CRM 2011中没有额外的IOrganizationService调用的情况下获取新创建的实体?

[英]How to obtain newly created entity without extra IOrganizationService call in Microsoft Dynamics CRM 2011?

I work with Microsoft Dynamics CRM 2011. Another service communicates with CRM via IOrganizationService. 我使用Microsoft Dynamics CRM 2011.另一项服务通过IOrganizationService与CRM通信。 In order to improve performance, I want to reduce the number of distinct calls. 为了提高性能,我想减少不同的调用次数。 Particularly, I wonder if it is possible to obtain newly created or updated entity with all the fields that are initialized during plugins execution without making an extra call to the IOrganizationService. 特别是,我想知道是否有可能获得新创建或更新的实体,其中包含在插件执行期间初始化的所有字段,而无需额外调用IOrganizationService。

As far as I know, it is possible in the newer versions of Microsoft Dynamics CRM. 据我所知, 有可能在Microsoft Dynamics CRM的新版本。 But is there a way it can be done in Microsoft Dynamics CRM 2011? 但有没有办法可以在Microsoft Dynamics CRM 2011中完成?

The link you are referring is for web api specific scenario. 您引用的链接是针对web api特定的方案。

In all plugin execution context, either create or update, pre or post operation we can get all the attributes of that particular record in target entity object from the context itself. 在所有插件执行上下文中,无论是创建还是更新,操作前或操作后,我们都可以从上下文本身获取目标实体对象中该特定记录的所有属性。

// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
    context.InputParameters["Target"] is Entity)
{
    // Obtain the target entity from the input parameters.
    Entity entity = (Entity)context.InputParameters["Target"];

For update, you can register Images to get all the other attribute values (pre-Image) which are not updated in that particular transaction, without making another service call. 对于更新,您可以注册图像以获取在该特定事务中未更新的所有其他属性值(前映像),而无需进行其他服务调用。

Read more 阅读更多

The answer is No in any version of CRM using OrganizationService calls. 在任何使用OrganizationService调用的CRM版本中,答案为否。 Assuming you have a scenario like the following: 假设您有如下情况:

Entity contact = new Entity("contact")
Guid contactId = _service.Create(contact);
Entity refreshedContact = _service.Retrieve("contact", contactId, new ColumnSet("new_fieldupdatedbyplugin"));

There is no more efficient way to get the value of contact.new_fieldupdatedbyplugin 没有更有效的方法来获取contact.new_fieldupdatedbyplugin的值

Within the context of plugin execution, Arun is certainly right, you can register a plugin on a Post execution step and reference the PostImage which will include all values updated by all plugins running on Pre execution steps. 在插件执行的上下文中,Arun肯定是正确的,您可以在Post执行步骤中注册插件并引用PostImage,其将包括在Pre执行步骤上运行的所有插件更新的所有值。 If you wanted to trigger some action based on a value set by a pre plugin, you could do it in a post plugin. 如果您想根据pre插件设置的值触发某些操作,可以在post插件中执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM