When to use ISPICKVAL, INCLUDES, and CONTAINS in the salesforce.



Requirement Overview

In this post, we are going to discuss When to use ISPICKVAL, INCLUDES, and CONTAINS in the salesforce. Sometime we get confused when we are applying in formula or validation rules. To solve this ambiguity , I thought to share this piece of information.

ISPICKVAL

ISPICKVAL is used for Picklist field. Say you need a validation rule that requires a user to fill out an explanation if they select “Other” as an Outcome reason . This validation rule formula requires that a user fill out the OutcomeReasonDescription if they set the OutcomeReason as “Other.”
ISPICKVAL(Outcome_reason__c, “Other”) &&
ISBLANK(Outcome_reason_Description__c)

ISPICKVAL(picklist_field, text_value) returns true if the value of picklist_field matches text_value, and false otherwise. You can combine ISPICKVAL() with PRIORVALUE(). You can use this function in assignment rules, validation rules, field updates, and workflow rules to find the previous value of a field.

INCLUDES

INCLUDES is used for Multi-select picklist. Whenever you are trying to verify the values present in multi-select picklist , you can opt for INCLUDES way to fulfill the need of the requirement.

INCLUDES(Hobbies__c, “Reading”) returns TRUE if one of the selected values in the Hobbies custom multi-select picklist field is Reading.

CONTAINS

CONTAINS usage

  1. Search for text.
  2. Check if an unknown string or character matches a defined set of strings or characters.

CONTAINS(Comments__c,”Demo”)
Returns TRUE if “Demo” is found anywhere in Comments__c.

Example of searching for unknown string or characters.

CONTAINS(“997654321”, TextField__c)
Will return true for TextField__c values such as 9,9,7,76,321, or any other substring of “997654321”

Conclusion

In summary, ISPICKVAL, INCLUDES, and CONTAINS are essential tools within the Salesforce platform that help developers and administrators to create efficient, accurate, and automated processes. Integrating these functions into your workflows, validation rules, formula fields, and queries will enhance the functionality and user experience of your Salesforce applications.

Hope you find this post useful! Catch you in the next content.
And thank you for being an awesome reader.
Share and grow together !!

If you have any doubts you can comment down below, I will try to reply ASAP.

Also keep visiting us, for more such content!

Adil Ansari

Md.Adil is a Senior Salesforce developer, a Computer Science graduate working on the Salesforce platform and providing customer solutions using force.com as a Salesforce consultant/developer. He is the founder of SalesforceBitsandBytes blogging site. He shares unique real time posts on different Salesforce implementations, the source code available on this SalesforceBitsandBytes blog is fully tested in the development environment.

Leave a Reply

Your email address will not be published. Required fields are marked *