0

我有一个名为 STATES 的选项集。另一个名为 RESTAURANTS。

我的目标是根据选择的状态过滤餐厅选项集。

我目前的方法是设计选项的值,其中:

States[0] = 1000
States[1] = 2000
States[2] = 3000

然后,餐厅:

Restaurants[3] = 1003
Restaurants[30] = 2004

然后,当 States 字段发生更改时,我会遍历餐厅。如果餐厅值不在所选状态的范围内,我调用removeOption(Restaurant.value)。

我的问题是,如果状态更改不止一次,每个值都将被删除,因为我没有“刷新”选项集或“replaceOption”。

有什么方法可以显示通过 removeOption 删除所有 optionSet 值,通过 javascript?

4

2 回答 2

2

A far better design would be to have two custom entities: one for states, one for restaurants. The restaurants entity would have a required (mandatory) lookup field (for a N:1 relationship) to States. Add lookups to both State and Restaurant where you would have had the picklists. You can then use built-in feature to filter one lookup based on the value of another. No code, no stress, almost zero maintenance.

Don't forget that you need to make sure users have "append to" privileges on

You can set up records for all the states easily enough by importing, and don't let users amend these. Import restaurants including the State information. You can use security roles to determine which users are allowed to create new restaurant records in future to make this really easy to keep up to date without it being an admin job.

I know this does not answer the question you asked about filtering picklists, but I am certain it answers your implied business requirement behind that.

于 2012-10-14T21:10:21.827 回答
2

您要做的是创建一个依赖选项列表。SDK 中有一个示例,在这篇针对 Crm 4 的博客文章这篇针对 2011 的 MSDN 文章中进行了解释

于 2012-10-13T09:08:46.850 回答