1

I want to show validation error if the selected lookup record type is not special. Below is the formula I am using.

ISPICKVAL(Type__c ,'In') && car__r.RecordType.Id <> '012q00000000V2R'

I have also tried creating recort type id formula field and record type name formula field and than compare with the value but that didn't help.Code for both of tham is as follows.

ISPICKVAL(Type__c ,'In') && car__r.RecordTypeId <> '012q00000000V2R'

and

ISPICKVAL(Type__c ,'In') && car__r.RecordTypeName <> 'Special'

None of the above code works as it does not give any error while I select type as In and select car from lookup of type Special.

Any help is really appreciated.

3 Answers 3

1

ISPICKVAL(Type__c ,'In') && car__r.recordtypeId <> '012q00000000V2R'

it will give error only if Picklist field Type is IN and recordType != Special. But if you want only RecordType validation then you only use

car__r.recordtypeId <> '012q00000000V2R'` 

or if you want to use both then you can use

OR(ISPICKVAL(Type__c ,'In') ,(car__r.recordtypeId <> '012q00000000V2R'))

ISPICKVAL(Type__c ,'In') || car__r.recordtypeId <> '012q00000000V2R'

Also i suggest you never direct reference Id. just store this into hierarchical Custom setting and then refer the custom setting. it will give you more control also if you move your field into another org or create a managed package then it will help you to update the value Note Also check that Validation rule is active.

11
  • Thanks for the efforts @Tushar. I want to through error only when Type__C is in and record type is Special. That is why i have used && also I need to know If I use record type name instead of id will that be identical in all orgs?
    – Ricky
    Oct 16, 2015 at 13:05
  • yes it is. Did it works for you i also share code with and condition. Oct 16, 2015 at 13:12
  • Hey Both of them are for or ? I don't see AND
    – Ricky
    Oct 16, 2015 at 13:14
  • check the first one. the first line Oct 16, 2015 at 13:16
  • Ohh I see that now so you mean to say I can straight use car__c instead of car__r ?
    – Ricky
    Oct 16, 2015 at 13:16
0

Just a guess, but you it might be happening that the Id's you are comparing are 15 and 18 digit Id's. A possible solution would be comparing 'DeveloperName' of record type instead of Id's. Hope it helps you.

0

You complete requirement is not clear from your question.

but from one of your comments "I want to through error only when Type__C is in and record type is Special."

then you should check both for equals.. but you are checking not equals for record type in your formula... change it to below and it should work

AND(
   ISPICKVAL(Type__c ,'In'),
   car__r.RecordTypeName = 'Special'
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.