Salesforce Certified Advanced Administrator | Field Comparison Functions

Field Comparison Functions

Question

An administrator would like to compare a field or expression to a list of static values.

Which of the following functions should be used?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B.

Out of the given options, the function that can be used to compare a field or expression to a list of static values is the "CONTAINS" function.

The "CONTAINS" function is used to check whether a text string contains a specific substring or not. It returns a Boolean value, i.e., "True" or "False" based on whether the string contains the substring or not.

Syntax: CONTAINS(text, compare_text)

Here, the "text" argument represents the text string that needs to be checked, and the "compare_text" argument represents the substring that needs to be searched within the text.

To compare a field or expression to a list of static values, the "CONTAINS" function can be used in the following way:

  1. Concatenate the list of static values with a delimiter character (such as a comma).

  2. Use the "CONTAINS" function to check whether the field or expression contains any of the static values.

Example:

Let's say we have a custom field called "Region" on the Account object, and we want to check whether the Region value is one of the following: "East", "West", or "South".

To do this, we can use the following formula in a validation rule or workflow rule:

CONTAINS(",East,West,South,", "," & Region & ",")

Explanation:

Here, we are concatenating the list of static values ("East", "West", and "South") with a delimiter (",") to form a string of the form ",East,West,South,".

We are then using the "CONTAINS" function to check whether the "Region" value is present in this string. To ensure an exact match, we are adding the delimiter character before and after the "Region" value (i.e., "," & Region & ",").

If the "Region" value matches any of the static values, the "CONTAINS" function will return "True", and the validation or workflow rule will be triggered. Otherwise, it will return "False".