0

I have an object A which has fields Country,State and Product Type. It is going to save the product types available in the state. Another object B which is going to save product details. When the user selects the country of B, I would like to show only the states corresponding to the country record in object A. Likewise When the user chooses State, only the product types corresponding to the Country & state combination should be shown. Also I would like to add validations to make sure always the product type available for the corresponding state and country is chosen.

Please suggest how to do this. I know we could use triggers, any other ways for doing it?

1

I highly suggest implementing the standard Country & State Picklists feature as a starting point since that work has already been done for you.

The last step in the dependency chain can be covered using Custom Metadata Types. Set one up which allows you to configure valid combinations of Country, State, and Product. Then, check each record against this configuration using a before event in your Apex Trigger.

  • Thanks, I didn't know about the Custom meta types. Anyway I could not use the standard Country& State picklists for various reasons. I have to create a global picklist or a custom object to save country,state and product types. Now if custom metadata types supported global picklist, I would have just used global picklists I mentioned to save the valid combinations. But It does not. The only option I see now is to create a custom obj to save the combinations, Is there any alternatives available? Also can this configuration be validated using validation rules? – Saranya Feb 1 '18 at 9:54
  • Country & State Picklists are global picklists... – Adrian Larson Feb 1 '18 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.