[SalesForce] Picklist value available for selection on change of record type

There is a custom object "XYZ" which has a picklist field "F1" with values 1, 2, 3, 11, 12, 13. There are two record types "A" and "B". For A, F1 has 1,2,3 set and for B, F1 has 11, 12, 13 set. User A creates a record R1 for XYZ with record type A and the value for F1 is 1. Now, the admin changes the record type of record R1 to B and then he sees the value 1 still in the picklist F1 while the available values should be 11, 12, 13. Is there a way so that the inapplicable value is not shown on record type change?

Best Answer

Actually you have two options to prevent situations as you have described. First option is to create validation rule on XYZ object that will check is value in picklist is related to record type. Follow the example:

OR( 
AND(
    RecordType.Name = 'A', 
    OR(
        ISPICKVAL(F1__c, '11'), 
        ISPICKVAL(F1__c, '12'), 
        ISPICKVAL(F1__c, '13')
    )
),
AND(
    RecordType.Name = 'B', 
    OR(
        ISPICKVAL(F1__c, '1'), 
        ISPICKVAL(F1__c, '2'), 
        ISPICKVAL(F1__c, '3')
    )
)

)

Second option is using Workflow Rule that will run everytime when user changes record type of XYZ object.

Follow the rule criteria:

ISCHANGED(RecordType)

This workflow should execute field update that will set picklist value. It is very easy to create it. During creation of workflow you should add new action, choose field update as a action type and select field to update (your picklist F1). You should be able to set this value to '-- None --'. If you want set it to first value that is related to record type, you have to create workflow rules for each record type. Each of them will be fired when user changes record type to value that is handled by workflow.

Related Topic