Dynamics CRM 2011:添加非实体表单字段

发布于 2024-11-16 05:04:57 字数 740 浏览 2 评论 0原文

我不断发现自己想要向 CRM 表单添加字段,但这些字段实际上并不代表实体上的物理字段。我希望这些字段在更新消息中发送,以方便我的插件...

例如,想象一下开箱即用的联系人/地址功能。主要联系地址在联系表单上显示为一组字段。然而,实际上,幕后发生了一些神奇的事情,导致为包含地址详细信息的联系人创建地址记录。我实际上不想重现这个,但这是一个公平的例子......

现在,我知道如何编写一个插件,它获取创建/更新消息中输入的地址字段,并将它们实际写入地址对象中。这很简单。看起来困难的部分是说服 CRM 在表单上显示字段以供用户输入地址数据。

我能看到做到这一点的唯一方法是在联系人等效表单中创建“假”字段,以便表单编辑器允许我将字段添加到对话框中。然后我必须在插件中过滤掉这些属性,这样假字段实际上不会写入数据库。

这可行,但涉及用假列填充数据库模式,这些假列将(或应该)永远不会在其中包含任何数据。这使得系统未来的定制更加混乱,因为所有 GUI 中都有名为“不要使用 - Address1”的诱饵字段。当我需要一个假的查找字段时,问题会变得更糟 - 这涉及创建一个假的关系。

那么:有没有一种方法可以实现同样的目的,而不需要在数据库模式中转储假垃圾?

也许有某种方法可以为表单上的 Javascript 中的任意属性创建表单字段,以便属性将包含在更新消息中?

当然,我意识到我可以使用 IFrame 或 Silverlight 来满足此要求,但我宁愿使用真正的 CRM 表单字段,并在更新/创建消息插件挂钩中处理数据。

I keep on finding myself wanting to add fields to CRM forms that don't actually represent physical fields on the entity. I want these fields to be sent in the Update message, for the benefit of my Plugins...

For example, imagine something like the out-of-the-box contact/address functionality. The main contact address is exposed as a set of fields on the Contact form. However, in actual fact there is some magic going on behind the scenes that causes an Address record to be created for the Contact containing the address details. I don't actually want to reproduce this, but it's a fair example...

Now, I know how to write a plugin that takes the address fields entered in the Create/Update message, and actually writes them into an Address object instead. That is simple enough. It seems the hard part is convincing CRM to display fields on the form for the user to enter the address data.

The only way I can see to do this is to create "fake" fields in the Contact-equivilent form, so that the form editor allows me to add the fields to the dialog. Then I have to filter these attributes out in a plugin, so the fake fields don't actually get written to the DB.

This would work, but involves filling the DB schema with fake columns that will (or should) never have any data in them. This makes future cusomisation of the system more confusing, as there are decoy fields called "DON'T USE - Address1" knocking around in all the GUIs. The problem gets worse when I need a fake Lookup field - this involves creating a fake relationship.

So: Is there a way to achieve the same thing without dumping fake garbage in the database schema?

Is there, perhaps, some way to create a form field for an arbitary attribute in Javascript on the form, such that the Attributes will be included in an Update message?

Sure, I realise I could IFrame or Silverlight something up to cater for this, but I'd rather use the genuine CRM form fields, and handle the data in the Update/Create message plugin hook.

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

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

发布评论

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

评论(1

双手揣兜 2024-11-23 05:04:57

不幸的是,您已经提到了我能想到的两个选项:假字段或自定义 IFrame。

我知道这感觉“肮脏”,但实际上我在做假字段的事情上并没有遇到太多麻烦。标准化命名约定是您的朋友。与 IFrame 相比,我更喜欢假字段,因为用户仍然可以在高级查找、报告、视图等中查询和过滤它们。

只需确保它们是只读的,并确保您的插件不会吞没异常 - 您希望异常冒泡并取消事务,而不是在没有子记录的情况下更新主记录的可能性。

Unfortunately, you have already mentioned the two options that I can think of: fake fields or custom IFrames.

I know it feels "dirty" but I actually haven't had much trouble doing the fake fields thing. Standardized naming conventions are your friend. I prefer fake fields over IFrames because users can still query and filter them in Advanced Find, reports, views, etc.

Just make sure they are readonly and make sure your plugins don't swallow exceptions - you want exceptions to bubble up and cancel the transaction instead of the possibility of the main record getting updated without the children.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文