Dynamics CRM 视图中的串联/计算列
我是 MS Dynamics 的新手,我想知道是否有一种方法可以将列添加到视图中,该视图是其他列的串联,例如:
Firstname + ' ' + Lastname As Fullname
似乎没有明显(优雅)的解决方案对此,我看到的所有建议都建议使用 javascript 来维护新属性。
更进一步,如果我想从另一列派生或计算一列,例如一个人的出生日期的年龄,这需要在视图加载时动态计算,对吗?同样,我无法立即找到一种方法来通过 CRM 框架提供这种简单的功能。也许我错过了什么?
任何建议将不胜感激。
I am new to MS Dynamics and I would like to know if there is a way of adding column to a view within that is a concatenation of some other columns, for example:
Firstname + ' ' + Lastname As Fullname
There doesn't seem like there is an obvious (elegant) solution to this, all the suggestions I have seen suggest using javascript to maintain an new attribute.
Taken one step further, if I want to derive or calculate a column from another column for example a person's age from their date of birth, this would need to be calculated on the fly when view loads, correct? Again I can't immediately see a way to provide this simple functionality with the CRM framework. Perhaps I am missing something?
Any advice would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你没有遗漏任何东西。对于您的问题,没有一个优雅的解决方案。如果您希望将其显示在视图中,则需要添加自定义列来显示它。
如果它确实经过计算(在数据库中存储固定值可能已经过时,如您的年龄示例),那么您需要在 Fetch 消息的后期步骤中添加一个插件,解析 XML 以确定您的实体是否返回时,解析出应计算的属性,计算值,然后将计算出的属性插入到结果 xml 中。
假设您不在视图中显示出生日期字段(您只想显示年龄),那么您还必须在“获取消息”的前期步骤中使用一个插件,解析XML 来确定您的实体是否是正在获取的实体,确定年龄列是否正在返回,如果是,则将计算基础列注入到正在返回的列集中。
请注意,如果您在 SSRS 报告中使用筛选视图,则不会执行这些插件步骤,因此在这些情况下您必须计算 TSQL 中的年龄。我认为您永远无法在 CRM 创建的向导报告中显示年龄列(您无法在此处获取 TSQL,并且插件将无法运行)。
考虑到所有这些,如果您有可以修复的东西(串联),我会在该实体的创建/更新插件中计算它,并将其存储在自定义属性(全名)中。在这种情况下,该属性将仅适用于网格视图、所有类型的报告等。
You're not missing anything. There is NOT an elegant solution to your problem. If you want it in a view you're going to need to add a custom column to display it.
If its truly computed (storing a fixed value in the database could be stale, as in your age example) then you'll need to add a plug-in on the post step of a Fetch message, parse the XML to determine if your entity is being returned, parse out the attributes which should be computed, compute the value, and then insert your computed attribute into the result xml.
Lets say you're not displaying the date of birth field in the view (you just want to display the age), then you're also going to have to have a plug-in on the pre step of the Fetch Message, parse the XML to determine if your entity is the one being fetched, determine if hte age column is being returned, and if so, inject the computation basis columns into the column set being returned.
Note that these plugin steps are NOT executed if you use the Filtered View's in SSRS reports, so you'd have to compute the age in TSQL in those cases. I don't think you'd ever be able to display the age column in CRM-created wizard reports (you can't get TSQL in here and the plugins won't run).
Given all that if you have something that CAN be fixed (concatentation), I would compute it in a create/update plugin for that entity and store it in a custom attribute (Fullname). In that case the attribute will just work for grid views, all flavors of reporting, etc.
Dynamics CRM 中没有什么比计算列更好的了。 benjnito 关于使用插件的说法是正确的,这是一个可行的解决方案。
但如果计算要在表单上显示的字段就足够了,我通常使用 JavaScript 来“伪造”一个属性。
为了让您了解如何做到这一点,这里有一段代码,我使用 jQuery 插入标签和只读文本框,以显示父记录字段值(在我的例子中是电话号码)。
There is nothing like computed columns in Dynamics CRM. benjynito is right about using plugins, that is a viable solution.
But if it is enough to calculate the field to be displayed on a form, I usually use JavaScript to "fake" an attribute.
To give you an idea how to do it, here is a snippet of code where I use jQuery to insert label and readonly textbox in order to display parent records field value (phone number in my case).
只需添加插件选项和 javascript 选项,还有安排任务来计算和设置属性的选项。例如,我已将这种技术用于“经过时间”属性,该属性需要每天更新。
该任务可以是使用 SDK 更新数据的自定义服务或计划控制台应用程序,也可以是 Scribe(或类似)作业。
Just to add that as well as the plugin option and javascript option, there's also the option of scheduling a task to calculate and set the attribute. I have used this technique for an 'elapsed time' attribute for example, where the attribute needed to be updated every day.
The task could be a custom service or scheduled console app that uses the SDK to update the data, or a Scribe (or similar) job.