Salesforce Developer Visualforce Formula Expression


// 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 

{! $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('', '') }

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 “” is contained within the 
string “”, 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.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License