[英]Updating entity in Dynamics 365 using CorrelationId context
I have set up a ServiceEndpoint in Dynamics 365 to send messages to Azure Service Bus.我在 Dynamics 365 中设置了一个 ServiceEndpoint 以将消息发送到 Azure 服务总线。 Whenever there is an update on an Account Entity a message is queued.
每当帐户实体有更新时,一条消息就会排队。 I have a service that is listening on this queue.
我有一个正在监听这个队列的服务。 My service is updating a property on the Account Entity that was queued.
我的服务正在更新排队的帐户实体上的属性。
My code is not executed as a plugin and does not implement IPlugin.我的代码没有作为插件执行,也没有实现 IPlugin。 This means that I do not have access to the IPluginExecutionContext.
这意味着我无权访问 IPluginExecutionContext。 To avoid an infinite loop I would like to use the CorrelationId as a context for my update calls.
为了避免无限循环,我想使用 CorrelationId 作为更新调用的上下文。
Is this possible?这可能吗?
This is what happens:这就是发生的事情:
My calls are using OrganizationServiceProxy我的电话正在使用 OrganizationServiceProxy
Why not use RemoteExecutionContext Class为什么不使用RemoteExecutionContext Class
Very quickly you can turn your Json(message) from Azure queue into Dynamics plugin context很快,您可以将您的 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;
}
and you can call it something like below你可以这样称呼它
RemoteExecutionContext pluginContext = GetContext(receivedBody);
Your issue is not with RemoteExecutionContext rather it is with trigger of plugin on Update of Account for Azure service bus.您的问题与 RemoteExecutionContext 无关,而是与 Azure 服务总线的帐户更新上的插件触发器有关。 You might know you can restrict update of Account to run only on fields you wish rather than all ie you can get message in your ASB queue on update of certain fields of Account.
您可能知道您可以限制帐户更新仅在您希望的字段上运行,而不是全部运行,即您可以在帐户的某些字段更新时在 ASB 队列中获取消息。
In addition if you want to handle with code, there is something called shared variables in Plugins .另外,如果你想处理代码, 在 Plugins 中有一个叫做共享变量的东西。 You can use them.
你可以使用它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.