[英]Updating entity in Dynamics 365 using CorrelationId context
我在 Dynamics 365 中設置了一個 ServiceEndpoint 以將消息發送到 Azure 服務總線。 每當帳戶實體有更新時,一條消息就會排隊。 我有一個正在監聽這個隊列的服務。 我的服務正在更新排隊的帳戶實體上的屬性。
我的代碼沒有作為插件執行,也沒有實現 IPlugin。 這意味着我無權訪問 IPluginExecutionContext。 為了避免無限循環,我想使用 CorrelationId 作為更新調用的上下文。
這可能嗎?
這就是發生的事情:
我的電話正在使用 OrganizationServiceProxy
為什么不使用RemoteExecutionContext Class
很快,您可以將您的 Json(message) 從 Azure 隊列轉換為 Dynamics 插件上下文
private static RemoteExecutionContext GetContext(string contextJson)
{
_log.Verbose($"Inside function {nameof(RemoteExecutionContext)}");
RemoteExecutionContext rv = null;
using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(contextJson)))
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(RemoteExecutionContext));
rv = (RemoteExecutionContext)ser.ReadObject(ms);
}
_log.Verbose($"Exit function {nameof(RemoteExecutionContext)}");
return rv;
}
你可以這樣稱呼它
RemoteExecutionContext pluginContext = GetContext(receivedBody);
您的問題與 RemoteExecutionContext 無關,而是與 Azure 服務總線的帳戶更新上的插件觸發器有關。 您可能知道您可以限制帳戶更新僅在您希望的字段上運行,而不是全部運行,即您可以在帳戶的某些字段更新時在 ASB 隊列中獲取消息。
另外,如果你想處理代碼, 在 Plugins 中有一個叫做共享變量的東西。 你可以使用它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.