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
BobBob 

Validation Rule for a Case page

I'm trying to create a validation rule that will stop a user from selecting an account that is not a service provider from a custom field. The validation rule needs to ignore everything else on the case page.

 

this is the custom field and it is a picklist.

 

Service_Provider__r.Service_Provider_Type__c

 

 

If someone could help, I would appreciate it

 

Best Answer chosen by Admin (Salesforce Developers) 
phiberoptikphiberoptik

What do you mean it needs to ifgnore the Service Provider field? The rule only works if the Service Provider field is not blank?

 

AND(
    NOT(ISBLANK(Service_Provider__c)),
    OR( 
       ISBLANK(TEXT(Service_Provider__r.Service_Provider_Type__c)),
       ISPICKVAL(Service_Provider__r.Service_Provider_Type__c, "On Vacation")
      )
)

 

All Answers

phiberoptikphiberoptik

Just to clarify, you are created a validation rule on the Case object right?

 

What value(s) would be in the Service_Provider__r.Service_Provider_Type__c field that should throw an error?

BobBob

"On Vacation"  or Blank, but i'm not sure how to add that blank or null value.

phiberoptikphiberoptik
OR(

   ISBLANK(TEXT(Service_Provider__r.Service_Provider_Type__c)),

   ISPICKVAL(Service_Provider__r.Service_Provider_Type__c, "On Vacation")

)

 

BobBob

This works good, but I need to add one more parameter. I need the rule to ignore the Service Provider field if it is blank. Something like the following. But the formula below does not work with the new parameter.

 

NOT( ISBLANK( TEXT( Service_Provider__c  ,


OR( ISBLANK(TEXT(Service_Provider__r.Service_Provider_Type__c)), ISPICKVAL(Service_Provider__r.Service_Provider_Type__c, "On Vacation") ))))

phiberoptikphiberoptik

What do you mean it needs to ifgnore the Service Provider field? The rule only works if the Service Provider field is not blank?

 

AND(
    NOT(ISBLANK(Service_Provider__c)),
    OR( 
       ISBLANK(TEXT(Service_Provider__r.Service_Provider_Type__c)),
       ISPICKVAL(Service_Provider__r.Service_Provider_Type__c, "On Vacation")
      )
)

 

This was selected as the best answer
BobBob

The formula before you modiified it what giving me an error when the service provider field was blank. The addition you made with the AND( NOT(ISBLANK(Service_Provider__c)) works perfectly .

 

Thank you so much!!! I really appreciate it.