如何更新 crm 2011 在线插件代码中的自定义实体?

发布于 2024-12-19 04:41:49 字数 543 浏览 5 评论 0原文

谁能告诉我为什么这段代码在 2011 年在线插件中不起作用?我想做的是更新自定义实体的集合。它在 service.Execute(...) 上引发以下错误。实现这一目标

的另一种方法备受赞赏...插件(执行)出现意外异常::System.InvalidCastException:指定的强制转换无效。

EntityCollection CustomEntitiesNeedingSync = service.RetrieveMultiple(RelevantCustomEntitiesQuery);

foreach (Entity currentCustomRecord in CustomEntitiesNeedingSync.Entities)
{
   UpdateRequest theUpdateRequest = new UpdateRequest();
   theUpdateRequest.Target = currentCustomRecord;
   service.Execute(currentCustomRecord);               
}

Can anyone tell me why this code doesn't work in an 2011 online plugin? What I'm trying to do is update a collection of custom entities. It throws the following error on the service.Execute(...). Another way to achieve this much appreciated...

Unexpected exception from plug-in (Execute): : System.InvalidCastException: Specified cast is not valid.

EntityCollection CustomEntitiesNeedingSync = service.RetrieveMultiple(RelevantCustomEntitiesQuery);

foreach (Entity currentCustomRecord in CustomEntitiesNeedingSync.Entities)
{
   UpdateRequest theUpdateRequest = new UpdateRequest();
   theUpdateRequest.Target = currentCustomRecord;
   service.Execute(currentCustomRecord);               
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

燃情 2024-12-26 04:41:49

您必须执行请求 - 而不是记录。

foreach (Entity currentCustomRecord in CustomEntitiesNeedingSync.Entities)
{
   UpdateRequest theUpdateRequest = new UpdateRequest();
   theUpdateRequest.Target = currentCustomRecord;
   service.Execute(theUpdateRequest);               
}

You have to execute the request - not the record.

foreach (Entity currentCustomRecord in CustomEntitiesNeedingSync.Entities)
{
   UpdateRequest theUpdateRequest = new UpdateRequest();
   theUpdateRequest.Target = currentCustomRecord;
   service.Execute(theUpdateRequest);               
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文