【问题标题】:How to obtain newly created entity without extra IOrganizationService call in Microsoft Dynamics CRM 2011?如何在 Microsoft Dynamics CRM 2011 中获取新创建的实体而无需额外的 IOrganizationService 调用?
【发布时间】:2019-10-28 14:01:01
【问题描述】:

我使用 Microsoft Dynamics CRM 2011。另一个服务通过 IOrganizationService 与 CRM 通信。为了提高性能,我想减少不同调用的数量。特别是,我想知道是否有可能在不额外调用 IOrganizationService 的情况下获得具有在插件执行期间初始化的所有字段的新创建或更新的实体。

据我所知,it is possible 在 Microsoft Dynamics CRM 的较新版本中。但是有没有办法可以在 Microsoft Dynamics CRM 2011 中完成?

【问题讨论】:

    标签: wcf dynamics-crm dynamics-crm-2011 microsoft-dynamics


    【解决方案1】:

    在任何使用 OrganizationService 调用的 CRM 版本中,答案都是“否”。假设您有如下场景:

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

    没有更有效的方法来获取contact.new_fieldupdatedbyplugin的值

    在插件执行的上下文中,Arun 肯定是对的,您可以在 Post 执行步骤中注册一个插件并引用 PostImage,其中将包含由在 Pre 执行步骤上运行的所有插件更新的所有值。如果你想根据 pre 插件设置的值触发一些动作,你可以在 post 插件中进行。

    【讨论】:

      【解决方案2】:

      您所指的链接是针对 web api 特定场景的。

      在所有插件执行上下文中,无论是创建还是更新、前置或后置操作,我们都可以从上下文本身获取目标实体对象中该特定记录的所有属性。

      // 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"];
      

      对于更新,您可以注册 Images 以获取在该特定事务中未更新的所有其他属性值(pre-Image),而无需进行其他服务调用。

      Read more

      【讨论】:

        猜你喜欢
        • 2018-09-22
        • 1970-01-01
        • 1970-01-01
        • 2013-01-19
        • 1970-01-01
        • 1970-01-01
        • 2012-04-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多