Salesforce Developer Visualforce Formula Expression

salesforce-developer-visualforce

```
// Salesforce - Developer - Visualforce - Formula Expressions:
Visualforce lets you use more than just global variables in the expression
language. It also supports formulas that let you manipulate values. For
example, the & character is the formula language operator that concatenates
strings.
{! $User.FirstName & ' ' & $User.LastName }
The above expression combines the logged in user’s first name and last name,
separating them with a space.
{! TODAY() }
{! TODAY() + 7 }
{! YEAR(TODAY()) }
{! DAY(TODAY() + 1) }
{! MAX(1,2,3,4,5,6,5,4,3,2,1) }
{! SQRT(49) }
{! CONTAINS('salesforce.com', 'force.com') }
Some functions, like TODAY(), have empty parenthesis, but some take parameters,
values that you want the function to use to do its calculation. In this example,
YEAR() takes a date parameter, which is provided by the TODAY() function, which
takes no parameters. The MAX() function can take any number of parameters.
The CONTAINS() function is especially interesting. It returns a Boolean value:
something that is either true or false. It compares two arguments of text and
returns true if the first argument contains the second argument. If not, it
returns false. In this case, the string “force.com” is contained within the
string “salesforce.com”, so it returns true.
There are dozens of functions that can be used in Visualforce. The list is
similar to, but not quite the same, as the functions available in formula
fields. Where they overlap the functions behave the same, so you can reuse most
of what you know about formula fields when you write Visualforce expressions.
```

page revision: 2, last edited: 04 Dec 2016 19:00