简体   繁体   English

如何更新webhook触发的azure函数中的记录?

[英]How to update the record in an azure function triggered by a webhook?

I have an Azure function triggered post creation of a record in Dynamics 365 CE. 我在Dynamics 365 CE中创建记录后触发了Azure功能。 The azure function and Dynamics 365 CE are integrated by a Webhook registered via the Plugin Registration. azure功能和Dynamics 365 CE由通过插件注册注册的Webhook集成。

What is the best way to update some data fields inside the record in RemoteExecutionContext . 更新RemoteExecutionContext中记录内部某些数据字段的最佳方法是什么。

Do I connect to Dynamics again or I can update as part of the Dynamics pipeline? 我是否再次连接到Dynamics,或者我可以作为Dynamics管道的一部分进行更新?

I have tried the .InputParameters["Target"].Id but upon updating with a new HttpClient I am getting a record not found error, whereas the webhook is in Post. 我已经尝试了.InputParameters["Target"].Id我在使用新的HttpClient进行更新时遇到了记录未找到错误,而webhook在Post中。

JObject Obj1 = new JObject();
Obj1.Add(STATE, 1);
Obj1.Add(STATUS, 123);
obj1.Add(ERROR_MESSAGE, "Update");

HttpRequestMessage updateApiRequest = new HttpRequestMessage(new HttpMethod("PATCH"), $"{d365Client.BaseAddress}new_customeentity1({targetEntity.Id.ToString()})");
updateApiRequest.Content = new StringContent(obj1.ToString(), Encoding.UTF8, "application/json");
HttpResponseMessage updateResposne = await d365Client.SendAsync(updateApiRequest );

What's the best way to achieve a similar integration? 实现类似集成的最佳方法是什么? How can I update the record within the pipeline without getting the Record Not Found error? 如何在不获取Record Not Found错误的情况下更新管道中的记录?

I would check two things for solving this particular "record not found" issue: 我会检查两件事来解决这个特殊的“未找到记录”问题:

  1. Try to register the step in "Asynchronous" mode if it's registered as "Synchronous" Read more 如果注册为“同步”,请尝试在“异步”模式下注册该步骤。 阅读更多内容
  2. Verify the code sample & important points explained in this blog . 验证此博客中解释的代码示例和重点。 Basically to avoid sandbox limitations and External Integration purpose only we go for Azure functions/webhooks 基本上为了避免沙箱限制外部集成目的,我们只使用Azure功能/ webhooks

So, if you are not doing anything else other than this simple update back to CRM record, then complete the service.Update in post-create plugin itself. 因此,如果除了这个简单的更新回到CRM记录之外你没有做任何其他事情,那么在post-create插件本身中完成service.Update

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM