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
@anilbathula@@anilbathula@ 

help using contains or include in validation rule

Hi guys,

 

I had a validation rule which throughs error when the previous value in a field  is 2012 and the new value is 2013.

And Stage Name is withdrawn.it work fines with my validation rule. but i want to simplify it .

here is my validation rule:-

 

AND($Profile.Name = "Custom System Admin",
ISPICKVAL(StageName,"Prospecting"),
OR(AND(ISPICKVAL(PRIORVALUE(DeliveryInstallationStatus__c),"Jan 2012"), ISPICKVAL(DeliveryInstallationStatus__c,"Jan 2013")),
AND(ISPICKVAL(PRIORVALUE(DeliveryInstallationStatus__c),"Jan 2012"), ISPICKVAL(DeliveryInstallationStatus__c,"sep 2013")),
AND(ISPICKVAL(PRIORVALUE(DeliveryInstallationStatus__c),"sep 2012"), ISPICKVAL(DeliveryInstallationStatus__c,"Jan 2013")),
AND(ISPICKVAL(PRIORVALUE(DeliveryInstallationStatus__c),"Sep 2012"), ISPICKVAL(DeliveryInstallationStatus__c,"sep 2013"))))

 

What i need instead of using  (ISPICKVAL(PRIORVALUE(DeliveryInstallationStatus__c),"Jan 2012")

like this can i using like this (ISPICKVAL(Contains(PRIORVALUE(DeliveryInstallationStatus__c),"2012"), ISPICKVAL(DeliveryInstallationStatus__c,"2013")) .

 

The Above code has 4 conditions if i use include or contains then it can be of 2 condition.

 

Thanks

Anil.B

 

Best Answer chosen by Admin (Salesforce Developers) 
SFDC_VikashSFDC_Vikash

Hi,

 

You can modify the formula as : 

AND($Profile.Name = "Custom System Admin",
ISPICKVAL(StageName,"Prospecting"),
Contains(TEXT(PRIORVALUE(DeliveryInstallationStatus__c )),"2012"), Contains(TEXT(DeliveryInstallationStatus__c),"2013")
)

 

Hope it will work for you.

 

Please mark it as solution if your problem is get solved by this so that others can also use this.

 

All Answers

SFDC_VikashSFDC_Vikash

Hi,

 

You can modify the formula as : 

AND($Profile.Name = "Custom System Admin",
ISPICKVAL(StageName,"Prospecting"),
Contains(TEXT(PRIORVALUE(DeliveryInstallationStatus__c )),"2012"), Contains(TEXT(DeliveryInstallationStatus__c),"2013")
)

 

Hope it will work for you.

 

Please mark it as solution if your problem is get solved by this so that others can also use this.

 

This was selected as the best answer
@anilbathula@@anilbathula@

Hi SFDC_Vikash,

 

Thanks for the post.

But i solved it before ur post.And forgot to update this.

How ever ur post is similar with my answer.

I mark it as solution.That others may benfit.

 

 

Thanks

Anil.B