如何以编程方式访问 CRM 4.0 设置?
我编写的一些插件(重新)计算各种价格,我使用 Math.Round 来保持结果的准确性,并使用 CRM 中默认的 2 位数字设置。
但我想……如果用户决定将他的 CRM 设置为使用不同的精度怎么办?
因此,我需要以编程方式访问 CRM 设置,以便我的功能可以与用户选择的任何设置配合使用。
我将如何从我的代码访问常规(以及可能的其他)CRM 设置?
Some of the plugins I wrote (re)calculate various prices, and I used Math.Round to keep results accurate with the default 2 digit setting in CRM.
But I figured... what if a user decides to set his CRM to use a different precision?
So, I need to access the CRM settings programmatically, so that my functions can work with whatever setting the user chooses.
How would I go about accessing the General (and, possibly, other) CRM settings from my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用户的设置存储在 usersettings 实体中。组织的设置存储在组织实体中
,但是特定属性存储在元数据中(例如,4 位精度的十进制)。您必须将元数据服务与 RetrieveAttribute 消息结合使用,这将返回属性的 AttributeMetadata。对于 CrmDecimal 属性,它将是 DecimalAttributeMetadata 的实例,例如包含配置的精度的属性。
哈
the settings of an user are stored in the usersettings entity. The settings of the organization are stored in the organization entity
However the settings for specific attributes are stored in the metadata (e.g. decimal with 4 digits precision). You have to use the Metadata service in combination with the RetrieveAttribute message which will return the AttributeMetadata for the attribute. For a CrmDecimal attribute it will be an instance of DecimalAttributeMetadata which has for example a property containing the configured precision.
hth
这是一个很好的技巧,您可以使用它来解决这个问题...
使用向导创建一个空白报告,将其导出为 RDP 文件并在 Visual Studio 中打开它。检查创建的数据集,其中之一称为“DSNumberAndCurrencyInfo”。
这是该数据集背后的查询。
这意味着有一个可用的 DB 函数,它会告诉您执行该函数的用户的各种格式设置。
您还可以深入挖掘并打开该功能,但您可能不需要这样做。
Here is a nice trick you can use to figure this out...
Create a blank report with wizard, export it do RDP file and open it in Visual Studio. Inspect created datasets, one of them is called "DSNumberAndCurrencyInfo".
This is the query behind that dataset.
It means that there is a DB function available that will tell you various format setting of the user that executed the function.
You could also dig deeper and open the function, but you probably will not need to.