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
Katie GrauerKatie Grauer 

Validation rule for two picklists

Hi All, I am having trouble with a validation rule. Originally I had the rule read ISPICKVAL( LeadSource, ""), which works fine, but I need to have the Stage "Prospecting" excluded. How would I write a formula to exclude "Prospecting"? Do I have to list all the other picklist valies for Stage?

Thanks!
Best Answer chosen by Katie Grauer
Mahesh DMahesh D
Hi Katie,

If you want to check only LeadSource
 
ISPICKVAL(LeadSource, 'Web')

If you want to exclude only StageName
 
NOT(ISPICKVAL(StageName, 'Prospecting'))

If you want to combindly check it then
 
AND(ISPICKVAL(LeadSource, 'Web'), NOT(ISPICKVAL(StageName, 'Prospecting')))

Along with the above answer given by me, Please follow the below information which will be helpful for you in the future.

AND
Description:Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. Use this function as an alternative to the operator && (AND).

Use:AND(logical1,logical2,...) and replace logical1,logical2,... with the values that you want evaluated.

Formula Field Example:IF(AND(Price<1,Quantity<1),"Small", null)
This formula displays “Small” if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one.

---------------------------------------------------------------------------------------------------------------------------

ISPICKVAL
Description:Determines if the value of a picklist field is equal to a text literal you specify.
Use:ISPICKVAL(picklist_field, text_literal) and replace picklist_field with the merge field name for the picklist; replace text_literal with the picklist value in quotes. text_literalcannot be a merge field or the result of a function.
Examples:
Contract Activation

IF(ISPICKVAL(Status, "Activated"), NOW()-ActivatedDate, null)calculates the number of days since the contract was activated. If the contract status is not “Activated,” this field is blank.

Commission Amounts
IF(ISPICKVAL(StageName, "Closed Won"), ROUND(Amount *0.02, 2), 0)

This example calculates the commission amount for any opportunity that has a “Closed Won” stage. The value of this field will be the amount times 0.02 for any closed/won opportunity. Open or lost opportunities will have a zero commission value.

Competitor-Triggered Workflow
ISPICKVAL(Stage, “Closed Lost”) && INCLUDES(Competitor__c, “Acme”)
In a workflow rule or the Process Builder, this formula configures Salesforce to trigger the associated actions if the Competitor multi-select picklist field on a lost business is Acme.

Tips:Replace picklist_field with a custom or standard field of type picklist.
Your text_literal expression must be of type text and enclosed in quotes. It cannot be a merge field or the result of a function.
Use CASE functions to determine if a picklist value is equal to a particular value.
When using the ISPICKVAL function to return the previous value of a picklist field, include the PRIORVALUE function inside the ISPICKVAL function as in this example:
ISPICKVAL(PRIORVALUE (picklist_field), text_literal)

--------------------------------------------------------------------------------------------------------------------------

NOT
Description:Returns FALSE for TRUE and TRUE for FALSE.
Use:NOT(logical) and replace logical with the expression that you want evaluated.
Example:IF(NOT(ISPICKVAL(Status, "Closed")), ROUND(NOW()-CreatedDate, 0), null checks to see if a variable is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number of days open rounded to zero decimal places. If the variable is not open, this field is blank.


Also find the below links:

https://help.salesforce.com/HTViewHelpDoc?id=customize_functions.htm&language=en_US

https://help.salesforce.com/htviewhelpdoc?err=1&id=customize_functions_a_h.htm&siteLang=en_US

https://help.salesforce.com/HTViewHelpDoc?id=customize_functions_i_z.htm&language=en_US


Please do let me know if it helps you.

Regards,
Mahesh

All Answers

Mahesh DMahesh D
Hi Katie,

Are you looking something like:
 
AND(ISPICKVAL(LeadSource, 'Web'), NOT(ISPICKVAL(StageName, 'Prospecting')))

Please do let me know if it helps you.

Regards,
Mahesh


 
Amit Chaudhary 8Amit Chaudhary 8
If you want to check StageName on opportunity only then pleas try below validation rule.
NOT(ISPICKVAL(StageName, 'Prospecting'))
If you are looking for both LeadSource and StageName.
AND(ISPICKVAL(LeadSource, 'Web'), NOT(ISPICKVAL(StageName, 'Prospecting')))

Let us know if this will help you.

 
Mahesh DMahesh D
Hi Katie,

If you want to check only LeadSource
 
ISPICKVAL(LeadSource, 'Web')

If you want to exclude only StageName
 
NOT(ISPICKVAL(StageName, 'Prospecting'))

If you want to combindly check it then
 
AND(ISPICKVAL(LeadSource, 'Web'), NOT(ISPICKVAL(StageName, 'Prospecting')))

Along with the above answer given by me, Please follow the below information which will be helpful for you in the future.

AND
Description:Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. Use this function as an alternative to the operator && (AND).

Use:AND(logical1,logical2,...) and replace logical1,logical2,... with the values that you want evaluated.

Formula Field Example:IF(AND(Price<1,Quantity<1),"Small", null)
This formula displays “Small” if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one.

---------------------------------------------------------------------------------------------------------------------------

ISPICKVAL
Description:Determines if the value of a picklist field is equal to a text literal you specify.
Use:ISPICKVAL(picklist_field, text_literal) and replace picklist_field with the merge field name for the picklist; replace text_literal with the picklist value in quotes. text_literalcannot be a merge field or the result of a function.
Examples:
Contract Activation

IF(ISPICKVAL(Status, "Activated"), NOW()-ActivatedDate, null)calculates the number of days since the contract was activated. If the contract status is not “Activated,” this field is blank.

Commission Amounts
IF(ISPICKVAL(StageName, "Closed Won"), ROUND(Amount *0.02, 2), 0)

This example calculates the commission amount for any opportunity that has a “Closed Won” stage. The value of this field will be the amount times 0.02 for any closed/won opportunity. Open or lost opportunities will have a zero commission value.

Competitor-Triggered Workflow
ISPICKVAL(Stage, “Closed Lost”) && INCLUDES(Competitor__c, “Acme”)
In a workflow rule or the Process Builder, this formula configures Salesforce to trigger the associated actions if the Competitor multi-select picklist field on a lost business is Acme.

Tips:Replace picklist_field with a custom or standard field of type picklist.
Your text_literal expression must be of type text and enclosed in quotes. It cannot be a merge field or the result of a function.
Use CASE functions to determine if a picklist value is equal to a particular value.
When using the ISPICKVAL function to return the previous value of a picklist field, include the PRIORVALUE function inside the ISPICKVAL function as in this example:
ISPICKVAL(PRIORVALUE (picklist_field), text_literal)

--------------------------------------------------------------------------------------------------------------------------

NOT
Description:Returns FALSE for TRUE and TRUE for FALSE.
Use:NOT(logical) and replace logical with the expression that you want evaluated.
Example:IF(NOT(ISPICKVAL(Status, "Closed")), ROUND(NOW()-CreatedDate, 0), null checks to see if a variable is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number of days open rounded to zero decimal places. If the variable is not open, this field is blank.


Also find the below links:

https://help.salesforce.com/HTViewHelpDoc?id=customize_functions.htm&language=en_US

https://help.salesforce.com/htviewhelpdoc?err=1&id=customize_functions_a_h.htm&siteLang=en_US

https://help.salesforce.com/HTViewHelpDoc?id=customize_functions_i_z.htm&language=en_US


Please do let me know if it helps you.

Regards,
Mahesh
This was selected as the best answer
Katie GrauerKatie Grauer
Thank you, this is perfect and I appreciate the resources. Slowly getting better with the formulas...
Mahesh DMahesh D
Hi Katie,

As you are new to this group, I would like to help you in marking the best answer so that it will be helpful to others in the future.

Go to the replay and select the Best Answer.

Regards,
Mahesh
Yamuna Doddi 10Yamuna Doddi 10
Hi ,

My requirement is two picklist values are need to be filled before saving the record. 
AND(ISPICKVAL(Status , 'Denied'),
(NOT(ISPICKVAL(Loss_Reason__c , ' '))))


Which is not working...  Suggestions are appreciated ... Thank you in advance