如何描述(枚举)对 Salesforce 中特定记录类型有效的选项列表实体?
在 apex 代码中,我想枚举选项列表字段的合法值。为此,我只需调用 Account.Foobar__c.getDescribe().getPickListValues()
即可获得 Schema.PickListEntry 值的列表。
但是,可以为给定的 sObject 设置多个记录类型。例如,帐户可能具有“制造商”、“分销商”和“零售商”记录类型。在 Salesforce 设置中,可以根据记录类型编辑(限制)每个字段的选项列表条目。因此,零售商类型帐户可能仅使用 Foobar 字段的选项列表值的子集。
所以基本上我想要 Account.Foobar__c.getDescribe().getPickListValues('Retailer')
但这不是语法。 validFor 方法看起来很有前途,但它似乎仅适用于字段相关选项列表 - 仅按记录类型过滤的选项列表对于 isDependentPicklist
返回 false。
In apex code I want to enumerate the legal values for a picklist field. To do this I can just call Account.Foobar__c.getDescribe().getPickListValues()
and I've got a list of Schema.PickListEntry values.
However it's possible to setup multiple record types for a given sObject. For example Account might have "Manufacturer", "Distributor" and "Retailer" record types. In the Salesforce setup it is possible edit (limit) the picklist entries for each field based on record type. So Retailer type accounts might only use a subset of the picklist values for the Foobar field.
So basically I want Account.Foobar__c.getDescribe().getPickListValues('Retailer')
however this is not the syntax. The validFor method looks promising, but it seems like it is only for field dependent picklists - a picklist filtered only by record type returns false for isDependentPicklist
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一篇旧帖子,但也许下面的信息会对仍然需要答案的人有所帮助。
我发现这里< /a> 实际上可以通过调用describeLayout() 来获取记录类型特定选项列表值的列表。
使用您的示例 (C#):
I know this is an old post, but maybe the info below will help someone who still needs the answer.
I found here that one can actually get a list of record type specific picklist values by making a describeLayout() call.
Using your example (C#):
不幸的是,你不能在纯粹的 Apex 中做到这一点。元数据 API 确实公开了它。
相关意见:http://boards.developerforce.com/t5/Apex-Code-Development/Any-way-to-obtain-picklist-values-by-record-type/td-p/287563
You can't do it in pure Apex AFAIK, unfortunately. The metadata API does expose it.
Related opinions: http://boards.developerforce.com/t5/Apex-Code-Development/Any-way-to-obtain-picklist-values-by-record-type/td-p/287563