I have a Multipicklist P1 with values 2,3,4. Now we have to introduce another picklist values a,b,c,d,e,f , which should be a dependent picklist for the first one. But I cannot afford for changing the above to picklist from multipicklist as that would be a data loss for previous/old records. So without changing its type how can I achieve this dependency relationship among those two picklist.
1 Answer
You can go for a Before Insert/Update trigger. Else you can simply write a validation rule i.e., If value 2 is selected in picklist1 and if the values are not equal to what is required then throw an error. This way you can avoid users enter wrong combination values in those picklists.
Try the below validation, I have written only for two conditions
AND(OR(
NOT includes(Test_Parent__c,"2"),
AND (NOT includes(Test_Dependents__c,"a"),
NOT includes(Test_Dependents__c,"b"),
NOT includes(Test_Dependents__c,"c"),
NOT isblank(Test_Dependents__c)
)
),
OR(
NOT includes(Test_Parent__c,"3"),
AND (
NOT includes(Test_Dependents__c,"d"),
NOT includes(Test_Dependents__c,"e"),
NOT includes(Test_Dependents__c,"f"),
NOT isblank(Test_Dependents__c)
)
) )
Basically it checks, If P1 equals 2 and If P2 not equal to OR does not contain a/b/c there will be an error. Likewise you can construct your validation rule.