function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
duubitduubit 

Validation Rule on Record Type Opportunity against Account record type

Hi.

 

I am totally stumped on this one, and this is a simple scenario:

 

1. VAL rule on opportunity (create or edit)

2. Check Opportunity Record Type name against Account record type name

3. If the first two letters are different then error

 

       LEFT(Account.Record_Type_Label__c,2)<>LEFT($RecordType.Name,2)

 

4. Account.Record_Type_Label__c is a formula referencing the Record type name on account

 

It will error when I say LEFT(Account.Record_Type_Label__c,2) =  LEFT($RecordType.Name,2) but when

I do not equal to no error ... what the?

 

Record type name example is Opp Rectype Name = US Opportunity and Account Rectype Name = AU Account

 

ANY ideas on this one? I need to use the first two letters, have also tried MID, no luck ...

Best Answer chosen by Admin (Salesforce Developers) 
Ron ReedRon Reed

You can't reference record type names across objects in validation rules this way. With #4 below, the Account.Record_Type_Label__c formula will actually return the Record Type Name of the opportunity (and not the Account Record Type Name). Basically you'll have to create a text field on Account and populate that text field with the record type name using a workflow rule (instead of using the formula) and use that in your validation rule instead. 

All Answers

phiberoptikphiberoptik

What is the formula you use for the Account.Record_Type_Label__c field?

Ron ReedRon Reed

You can't reference record type names across objects in validation rules this way. With #4 below, the Account.Record_Type_Label__c formula will actually return the Record Type Name of the opportunity (and not the Account Record Type Name). Basically you'll have to create a text field on Account and populate that text field with the record type name using a workflow rule (instead of using the formula) and use that in your validation rule instead. 

This was selected as the best answer
duubitduubit

Hi.

 

The formula on the account is just 

 

$RecordType.Name but does not matter what I do, whether I use BEGINS, LEFT, it will only error

if I say LEFT(Account.Record_Type_Label__c,2) = LEFT($RecordType.Name,2)

 

When I know that the first two letters of the Account record type and the first two letters

of the Opportunity record type are different on the screen.

 

Even if I do Account.Record_Type_Label__c = $RecordType.Name. I get an error but on <> I get squat...

 

It does not matter whether I create the record or edit, same scenario. Just trying to validate the Account Record

Type name verses the Opportunity record type name... any ideas??