簡體   English   中英

在 Dynamics CRM 插件中更改記錄所有者

[英]Change record owner in Dynamics CRM plugin

我正在寫一個更改所有者的 Post 插件。 當所有者有替代經理時,所有者將更改為替代經理。 我嘗試了 service.Update 和 AssignRequest,但這些都引發了異常。

當我發布請求時,我的實體無法更新(然后在 10:00:00 之后等待回復時拋出“請求通道超時”)。 但是就像我看到的那樣,沒有遞歸,因為當我記錄它時,我只有一次重復的日志,並且它在更新之前或在線停止。

var assignedIncident = new AssignRequest
{
  Assignee = substManagerRef, //get it throw another method, alreay checked in test it`s correct
  Target = new EntityReference ("incident", incedentId)
};
service.Execute(assignedIncident);

我試圖用另一種方式寫目標

Target = postEntityImage.ToEntityReference()

我試圖編寫簡單的更新,但問題是一樣的。

Entity incident = new Entity("incident" , incidentId);
incident["ownerid"] = substManagerRef:
service.Update(incident);

有人可以幫我嗎? 或者也許展示解決它的方法)

該插件正在觸發自身並進入循環。 系統僅允許在插件深處最多進行 8 次調用,這就是它引發錯誤並回滾事務的原因。

要解決此問題,請按以下方式重新設計您的插件:

  • 在 PreValidation 階段在您的實體的更新消息上注冊您的插件。
  • 在插件中,從 InputParameters 集合中選擇Target屬性。
  • 這是一個Entity類型。 修改或設置此Entity object 的ownerid屬性。

就這些。 您不需要進行更新,您的修改現在已傳遞到插件管道中。

注意:對於EntityReference屬性,此技術僅在您的插件在 PreValidation 階段注冊時才有效。 對於其他常規屬性,它也適用於 PreOperation 階段。

暫無
暫無

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

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