如何在 Microsoft Dynamics CRM 2011 中不额外调用 IOrganizationService 获取新创建的实体?
How to obtain newly created entity without extra IOrganizationService call in Microsoft Dynamics CRM 2011?
我使用 Microsoft Dynamics CRM 2011。另一个服务通过 IOrganizationService 与 CRM 通信。为了提高性能,我想减少不同调用的次数。特别是,我想知道是否有可能在不额外调用 IOrganizationService 的情况下获得新创建或更新的实体,其中包含在插件执行期间初始化的所有字段。
据我所知,it is possible 在较新版本的 Microsoft Dynamics CRM 中。但是有没有一种方法可以在 Microsoft Dynamics CRM 2011 中完成?
您所指的 link 适用于网络 api 特定场景。
在所有插件执行上下文中,无论是创建还是更新、预操作或 post 操作,我们都可以从上下文本身获取目标实体对象中该特定记录的所有属性。
// 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),而无需进行另一个服务调用.
在任何使用 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,其中将包含所有插件更新的所有值 运行 执行前步骤。如果你想根据预插件设置的值触发一些动作,你可以在 post 插件中完成。
我使用 Microsoft Dynamics CRM 2011。另一个服务通过 IOrganizationService 与 CRM 通信。为了提高性能,我想减少不同调用的次数。特别是,我想知道是否有可能在不额外调用 IOrganizationService 的情况下获得新创建或更新的实体,其中包含在插件执行期间初始化的所有字段。
据我所知,it is possible 在较新版本的 Microsoft Dynamics CRM 中。但是有没有一种方法可以在 Microsoft Dynamics CRM 2011 中完成?
您所指的 link 适用于网络 api 特定场景。
在所有插件执行上下文中,无论是创建还是更新、预操作或 post 操作,我们都可以从上下文本身获取目标实体对象中该特定记录的所有属性。
// 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),而无需进行另一个服务调用.
在任何使用 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,其中将包含所有插件更新的所有值 运行 执行前步骤。如果你想根据预插件设置的值触发一些动作,你可以在 post 插件中完成。