1

I have a text field called Region. This field is receiving data from several APEX classes and a few flows as well, so I shouldn't change the field type. The purpose of that field is to store a city name for a record (we have about 20 city names).

Then I have a picklist field called Entity Code. What we need now is to make the Entity Code dependant of the Region field (for example, if Region = Shanghai, then Entity Code picklist should only show the values related to Shanghai). However, because Region is not a picklist, I cannot create a dependency between the two fields.

I was thinking to create an additional picklist called RegionClone containing the 20 city names as values and then have workflows rules to update RegionClone based on the Region text field value. But that means having many workflow rules in place, which I think it's not optimal.

Is there any other way I could achieve a dependency between text field and picklist?

2 Answers 2

0

Unfortunately, the only standard way to achieve what you want is the dependent picklist option. You're right to be cautious about changing the Type of your Region field, but this is entirely doable. You can ensure no data issues by either:

  • Not enabling the 'restrict picklist to only specified values' checkbox
  • Using your existing data to generate a set of distinct Region values, then making sure your picklist has all of these as options

Alternatively, you could also do one of the below. I'm listing these because they're possible, but you should recognise they're terrible solutions:

  • Put in place a validation rule to ensure the Entity Code value is one of those permitted for the Region (a potentially huge IF statement, that would certainly annoy Users)
  • Hide the entity code field from the page layout and create an entirely new custom component (VF/ Lightning) just to update this one field, that handles the Entity Code value restrictions
1
  • Thanks for the answer, Is this about visual SF or some field level, Text dependent on Picklist field? came across this problem to show a question when one the picklist is selected. Can we do it without VF or Screen flow in SFDC?
    – tough
    Sep 10, 2021 at 13:38
0

Since you have just 20 city names , you can create Entity Code as the formula field to populate it depending on whatever is the value in the Region field. Alternatively, you can store the mapping of Region and Entity code in the custom setting or custom metadata and access it in apex class/ trigger to populate the entity code , fetching the mapping from the custom setting.

2
  • I thought about your first solution but the problem is that Entity Code could have multiple values based on the Region and the user should be able to select the entity code he needs. If I make Entity Code as a formula, I can only show one value to the user. Do you have some examples about the second solution? Jan 22, 2020 at 16:29
  • Did you mean for a specific Region , there will be multiple Entity codes and user can select a single value out of the multiple entity codes? Jan 23, 2020 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .