簡體   English   中英

如何在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。

據我所知, 有可能在Microsoft Dynamics CRM的新版本。 但有沒有辦法可以在Microsoft Dynamics CRM 2011中完成?

您引用的鏈接是針對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"];

對於更新,您可以注冊圖像以獲取在該特定事務中未更新的所有其他屬性值(前映像),而無需進行其他服務調用。

閱讀更多

在任何使用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插件中執行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM