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 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 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 usage
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”
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!