Decode
Compares one expression to one or more other expressions. When the base expression matches a search expression, returns the corresponding result expression. When no match is found, returns the default expression when specified, or null when it is not. This function is similar to an if-then function.
Syntax
decode(expr, search, result [, search , result]... [, default])
Enabled for
Search/Dashboard | No |
Business Rules | Yes |
Quick Actions | Yes |
Workflow Objects | Yes |
Reports | No |
Parameters
This function must have at least four parameters, and can have an unlimited number of parameters.
expr | Expression to evaluate. |
search | Text to match exactly with the search expression. |
result | Value to return if the previous search text is matched. |
default | Value to return if no matches are found. |
Return Value
Number value or text value.
Example
$(decode("Impact", "High", 1, "Medium", 2, "No Matches"))
If the field called Impact has the value High, then this functions returns 1. If the field called Impact has the value Medium, then this function returns 2. If the field called Impact has any other value, this function returns the text value "No Matches".