如何更新 crm 2011 在线插件代码中的自定义实体?
谁能告诉我为什么这段代码在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须执行请求 - 而不是记录。
You have to execute the request - not the record.