Pages

Thursday, July 18, 2013

Salesforce Field Dependencies deployment

Field Dependencies is one of basic, simple, but very powerful feature from Salesforce.com and has been release long time back. This blog is not about on how to create field dependency, but more on field dependency deployment.

What is deploy mean here? It is deploy from one instance to another instance in Salesforce. Then, next question, Why we need to deploy such a simple thing?
Cannot we just create or update in Production instance directly? - Yes, of course you can.
But, when you have a big list of dependency field and by standard best-practice, you should:
- change it in sandbox instance
- get user to test it in sandbox instance and approve
- deploy it to production

Okay, now we are clear why need to "deploy" such a simple thing like field dependency.

Use case: a global company present in many countries and cities around the world. Both country and city is picklist value, city must be valid only for a country, this is pretty basic and field dependency is best solution available city value is dependent on country selection. Since company is growth very rapidly, admin need keep to update city within country, or even remove city which no longer valid.

Deployment

After user test and approve in sandbox, here are steps to deploy using Change Sets:
  • Go to Setup - Deploy - Outbound Change Sets
  • Create new Change Set, type a Name and Description, always add description on what will be add into this change set
  • In the Change Set Components, look for Custom Field
  • Find and add Dependent Field (not Controlling field, unless it is needed)
  • Upload to Production instance
  • Switch  to Production instance, Setup - Deploy - Inbound Change Sets and find the new Change Set name
  • You may Validate before Deploy to make sure everything is good
  • Done
I believe you can do the same using Force.com IDE to deploy, similar result using Change Set.

Notes: if you have records with old dependent field which no longer there, the old value will remind there until you update it manually, so don't afraid this exercise will update all existing data.

If you have Record Type on that object, you need to add the new values in Picklists Available for Editing, otherwise the new picklist values will not shown in page layout, although it is added in Field Dependency.