MS CRM - 获取导致表单保存的字段
我有一个 MS CRM 4 表单,当某些字段发生更改时,我需要将这些字段写入 Excel 工作表。
因此,我编辑了表单字段 onchange 事件以调用 crmform.save(),这会触发一个插件运行,将字段值写入 Excel 工作表的命名范围(1 个单元格)。
但是,我不知道哪个字段导致了保存。有没有办法获取这些信息? (并非表单上的所有字段都需要转到 Excel 工作表)
如果我使用此: DynamicEntity target = (DynamicEntity)Context.InputParameters[ParameterName.Target]; 我可以查看特定字段,但我无法知道哪些字段发生了变化。
有什么建议吗?
I have a MS CRM 4 form where when certain fields are changed, I need those fields to be written to an excel sheet.
So, I edited the form field onchange event to call crmform.save() which triggers a plugin to run that writes the field value to a named range (1 cell) of an excel sheet.
However, I don't know which field caused the save. Is there a way to get that information? (Not all fields on the form need to go to the excel sheet)
If I use this: DynamicEntity target = (DynamicEntity)Context.InputParameters[ParameterName.Target];
I can look at specific fields, but I have no way of knowing which ones changed.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
根据我的经验,当您更新实体时,只有更改的字段才有价值(在 DynamicEntity 中)。假设您有一个具有名字和姓氏的实体。如果您只更改姓氏并保存。 LastName 将有一个值,但 FirstName 将为 null(除非您有一些 javascript 代码强制提交 FirstName)。
It's my experience that only the changed fields will have value (in the DynamicEntity) when you update an entity. So let's say you have an entity with a FirstName and Lastname. If you only change the LastName and save. The LastName will have a value however FirstName with be null (unless you have som javascript code that forces the FirstName to be submitted).
如果您的插件在实体更新的前置事件上触发,您应该能够将
IPluginExecutionContext.PreEntityImages
与您从中获取的DynamicEntity
进行比较目标
。或者,如果您的插件在更新的后事件上触发,您应该能够将
IPluginExecutionContext.PreEntityImages
与IPluginExecutionContext.PostEntityImages
进行比较。If your plugin is triggered on the Pre-Event of the Update on your entity, you should be able to compare the
IPluginExecutionContext.PreEntityImages
to yourDynamicEntity
that you've fetched from theTarget
.Or if your plugin is triggered on the Post-Event of the Update, you should be able to compare the
IPluginExecutionContext.PreEntityImages
withIPluginExecutionContext.PostEntityImages
.看起来您已经采取了不同的方式,但另一个建议是创建一个隐藏字段 - “FieldThatChanged”。在字段 on-change javascript 中,将该字段设置为已更改字段的名称,然后在插件中访问该字段。
Looks like you are already going a different way, but another suggestion is to create a hidden field - "FieldThatChanged." In your field on-change javascript, set that field to the name of the field that changed, then access that in your plugin.
是的,完全改变了我处理这个问题的方式。我在 iframe 中使用 jquery 将我想要的所有精确字段(名称/值对)传递给在 ISV 文件夹中运行的 ASPX 文件的方法,该方法采取必要的操作。谢谢大家的建议!
Yep, totally changed the way I approached this. I'm using jquery in an iframe to pass all the exact fields (name/value pairs) I want to a method of an ASPX file running in the ISV folder that takes the neccesary action. Thanks for the suggestions all!
我建议使用@Forgotten Semicolon 建议的前图像和后图像。此外,还设置过滤属性,以便仅在您关心的字段发生更改时触发插件。
I recommend using the Pre and Post Images as suggested by @Forgotten Semicolon. And in addition set the Filtering Attributes so the Plugin is triggered only on the change of the fields you care about.