[SalesForce] Validation rule on a text field based on Role

I want to create a validation rule on a look up field based on role . There are two roles

  1. Member Member – is a member
  2. Member PA – is a pa to the member

lookup fields – REP_Customer_Representative__c (lookup to Account)

The requirement is when a "member member" creates a case and if the look up field is blank the validation rule should not fire as REP_Customer_Representative__c – is a member representing field

But when a "Member Pa" creates a case he/she should not leave the lookup field REP_Customer_Representative__c – blank

and this is what i came up with, but the validation rule is not getting fired

AND( ISBLANK(REP_Customer_Representative__c), 
$UserRole.Name = 'Member_PA' ) 

Best Answer

I don't know if this is the answer, but try:

AND( ISBLANK(REP_Customer_Representative__r.Id), 
$UserRole.Name = 'Member_PA' ) 

I seem to recall the validation rules needing to look up a value on the parent (i.e. REP_Customer_Representative__r.Id), not just where there is a value in that field itself.

Let us know if this works... or not.

Related Topic