+ Start a Discussion
Mr SlingMr Sling 

Changing Case Record Type doesn't automatically change Type picklist - Validation Rule or?

We have a few dependent picklists for our cases, and the dependent picklist chains all start with the "Type" field.  We just implemented multiple Case Record Types to help us keep our 'Type' field (and it's dependent picklists) tidy.  We have a 1-to-1 direct relationship between our Case Record Types and Types --> IE: Case Record Type "Presales" only has 1 Type, also "Presales".

 

Unfortunately, when a user clicks the <CHANGE> link next to the Case Record Type and changes the Record Type, the "Type" dependent picklist doesn't automatically change to the new and users can incorrectly save say, a 'Presales' cases as a 'Technical' type.

 

I thought about putting in a Validation Rule but I'm having a hard time finding where/how to make a Validation Rule on the Case Record Type.

 

I could very well be going about the root of this problem completely backwards, too.  Any ideas?

Ispita_NavatarIspita_Navatar

clean implementation would be implementing a trigger which on "Update"
in this case change of Recordtype also changes the "Type" field accordingly or in case you have multiple values for for a particular type , it can be set to none, else you can also implement a validation rule via trigger
in case RecordType is Presales and the type of value is something other than "Presales" you can raise error
Please refer to the sample code below:-
trigger CaseTgr on Case (after update) {
String strCaseRecordTypeName;
Case caseTemp = [Select id, RecordType.Name from Case where id = :Trigger.new[0].id];
strCaseRecordTypeName = caseTemp.RecordType.Name;
    if(strCaseRecordTypeName != 'Presales' && Trigger.new[0].type=='Presales')
    {
       Trigger.new[0].type.adderror('In-correct picklist value for recordtype -'+strCaseRecordTypeName );
        // in the above line - Trigger.new[0].type refers to the the new value for type specified by user during editing recordtype
        // Trigger.new[0].type.adderror- this whole expression makes the error to appear at the field specified here type
    }
}

I have put in code for 1 recordtype only you can add others similarly.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.