global variable in salesforce   Leave a comment

$Action
$Api
$Component
$componentLabel
$CurrentPage
$Label
$Label.Site
$ObjectType
$Organization
$Page, $Profile
$Resource
$Site
$System.OriginDateTime
$User
$User.UITheme and $User.UIThemeDisplayed
$UserRole

——————————————————————————————————————————————————————–


Something inside visual force page

Functions

You can use the following operators and functions in your Visualforce pages.

Math Operators

Operator Description Use
+ Calculates the sum of two values. value1 + value2 and replace each value with merge fields, expressions, or other numeric values.
Calculates the difference of two values. value1 – value2 and replace each value with merge fields, expressions, or other numeric values.
* Multiplies its values. value1 * value2 and replace each value with merge fields, expressions, or other numeric values.
/ Divides its values. value1 / value2 and replace each value with merge fields, expressions, or other numeric values.
^ Raises a number to a power of a specified number. number^integer and replace number with a merge field, expression, or another numeric value; replace integer with a merge field that contains an integer, expression, or any integer.
() Specifies that the expressions within the open parenthesis and close parenthesis are evaluated first. All other expressions are evaluated using standard operator precedence. (expression1) expression2… and replace each expressionwith merge fields, expressions, or other numeric values.

Logical Operators

Operator Description Use
= and == Evaluates if two values are equivalent. expression1=expression2 or expression1 == expression2, and replace each expression with merge fields, expressions, or other numeric values.
<> and != Evaluates if two values are not equivalent. expression1 <> expression2 or expression1 != expression2, and replace each
expression with merge fields, expressions, or other numeric values.
< Evaluates if a value is less than the value that follows this symbol. value1 < value2 and replace each
value with merge fields, expressions, or other numeric values.
> Evaluates if a value is greater than the value that follows this symbol. value1 > value2 and replace each value with merge fields, expressions, or other numeric values.
<= Evaluates if a value is less than or equal to the value that follows this symbol. value1 <= value2 and replace each
value with merge fields, expressions, or other numeric values.
>= Evaluates if a value is greater than or equal to the value that follows this symbol. value1 >= value2 and replace each
value with merge fields, expressions, or other numeric values.
&& Evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND. (logical1) && (logical2) and replace logical1 andlogical2 with the values or expressions that you want evaluated.
|| Evaluates if at least one of multiple values or expressions is true. Use this operator as an alternative to the logical functionOR. (logical1) || (logical2) and replace any number of logical references with the values or expressions you want evaluated.

Text Operators

Operator Description Use
& Connects two or more strings. string1&string2 and replace each string with merge fields, expressions, or other values.

Date and Time Functions

Note

The date/time data type might not evaluate correctly in formula expressions for Visualforce pages with an API version less than 20.0. It may be incorrectly interpreted as just a date type.
Function Description Use
DATE Returns a date value from year, month, and day values you enter. Salesforcedisplays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year. DATE(year,month,day) and replace year with a four-digit year, month with a two-digit month, and daywith a two-digit day.
DATEVALUE Returns a date value for a date/time or text expression. DATEVALUE(expression) and replaceexpression with a date/time or text value, merge field, or expression.
DATETIMEVALUE Returns a year, month, day and GMT time value. DATETIMEVALUE(expression) and replaceexpression with a date/time or text value, merge field, or expression.
DAY Returns a day of the month in the form of a number between 1 and 31. DAY(date) and replace date with a date field or value such as TODAY().
MONTH Returns the month, a number between 1 (January) and 12 (December) in number format of a given date. MONTH(date) and replace date with the field or expression for the date containing the month you want returned.
NOW Returns a date/time representing the current moment.

The
NOW function returns the current date and time in the GMT timezone.
{!NOW()}

For example:

Today's date and time is: {!NOW()}

produces the following:

Today's date and time is: Mon Jul 21 16:12:10 GMT 2008

Tips

  • Do not remove the parentheses.
  • Keep the parentheses empty. They do not need to contain a value.
  • Use addition or subtraction operators and a number with a
    NOW function to return a different date and time. For example
    {!NOW() +5}

    calculates the date and time five days ahead of now.

  • If you prefer to use a date time field, use TODAY.
NOW()
TODAY Returns the current date as a date data type.

The
TODAY function returns the current day. For example, The following markup:

Today's date is: {!TODAY()}

produces the following output:

Today's date is Mon Jul 21 00:00:00 GMT 2008

Tips

  • Do not remove the parentheses.
  • Keep the parentheses empty. They do not need to contain a value.
  • Use addition and subtraction operators with a
    TODAY function and numbers to return a date. For example
    {!TODAY() +7}

    calculates the date seven days ahead of now.

  • If you prefer to use a date time field, use NOW.
TODAY()
YEAR Returns the four-digit year in number format of a given date. YEAR(date) and replace date with the field or expression that contains the year you want returned.

Informational Functions

Function Description Use
BLANKVALUE Determines if an expression has a value and returns a substitute expression if it does not. If the expression has a value, returns the value of the expression. BLANKVALUE(expression,substitute_expression) and replace expression with the expression you want evaluated; replacesubstitute_expression with the value you want to replace any blank values.
ISBLANK Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE. ISBLANK(expression) and replace expression with the expression you want evaluated.
NULLVALUE Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression is not blank, returns the value of the expression. NULLVALUE(expression,substitute_expression) and replace expression with the expression you want to evaluate; replacesubstitute_expression with the value you want to replace any blank values.
PRIORVALUE Returns the previous value of a field. PRIORVALUE(field)

Logical Functions

Function Description Use
AND Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false.

The following markup displays the word “Small” if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one.

{!IF(AND(Price < 1,
                    Quantity < 1),
                    "Small", null)}

You can use
&&

instead of the word
AND

in your Visualforce markup. For example,
AND(Price < 1, Quantity < 1)

is the same as
(Price < 1) && (Quantity < 1)

.

  • Make sure the value_if_true and value_if_false expressions have the same data type.
AND(logical1,logical2,…) and replacelogical1,logical2,… with the values that you want evaluated.
CASE Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it is not equal to any values, it returns the
else_result.
CASE(expression,​value1result1,value2,​ result2,…,​ else_result) and replace expression with the field or value you want compared to each specified value. Replace each value and result with the value that must be equivalent to return the result entry. Replace else_result with the value you want returned when the expression does not equal any values.
IF Determines if expressions are true or false. Returns a given value if true and another value if false.

The following markup returns “Private” if the opportunity IsPrivate field is set to true; it returns “Not Private” if the field is set to false.

{!IF(opportunity.IsPrivate, "Private", "Not Private")}
IF(logical_testvalue_if_true,value_if_false) and replace logical_test with the expression you want evaluated; replace value_if_truewith the value you want returned if the expression is true; replace value_if_false with the value you want returned if the expression is false.
ISCHANGED Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE. ISCHANGED(field) and replace field with the name of the field you want to compare.
ISNEW Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE. ISNEW()
ISNUMBER Determines if a text value is a number and returns TRUE if it is. Otherwise, it returns FALSE. ISNUMBER(text) and replace text with the merge field name for the text field.
NOT Returns FALSE for TRUE and TRUE for FALSE.

The following markup returns the value of ReportAcct if the accountIsActive field is set to false. It returns the value of SaveAcct if IsActiveis set to true.

{!IF(NOT(Account.IsActive)ReportAcct, SaveAcct)}

You can use
!

instead of the word
NOT

in your Visualforce markup. For example,
NOT(Account.IsActive)

is the same as
!Account.IsActive)

.

NOT(logical) and replace logical with the expression that you want evaluated.
OR Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false.

The following markup will return the value of VerifyAcct if either account field IsActive__c or IsNew__c is set to true.

{!IF(OR(Account.IsActive__c, 
                    Account.IsNew__C)) 
                    VerifyAcct, CloseAcct)}

You can use
||

instead of the word
OR

in your Visualforce markup. For example,
OR(Price < 1, Quantity < 1)

is the same as
((Price < 1) || (Quantity < 1))

.

OR(logical1logical2…) and replace any number of logical references with the expressions you want evaluated.

Math Functions

Function Description Use
ABS Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign. ABS(number) and replace number with a merge field, expression, or other numeric value that has the sign you want removed.
CEILING Rounds a number up to the nearest integer. CEILING(number) and replace number with the field or expression you want rounded.
EXP Returns a value for e raised to the power of a number you specify. EXP(number) and replace number with a number field or value such as 5.
FLOOR Returns a number rounded down to the nearest integer. FLOOR(number) and replace number with a number field or value such as 5.245.
LN Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904. LN(number) and replace number with the field or expression for which you want the natural logarithm.
LOG Returns the base 10 logarithm of a number. LOG(number) and replace number with the field or expression from which you want the base 10 logarithm calculated.
MAX Returns the highest number from a list of numbers. MAX(numbernumber,…) and replace number with the fields or expressions from which you want to retrieve the highest number.
MIN Returns the lowest number from a list of numbers. MIN(numbernumber,…) and replace number with the fields or expressions from which you want to retrieve the lowest number.
MOD Returns a remainder after a number is divided by a specified divisor. MOD(numberdivisor) and replace number with the field or expression you want divided; replace divisor with the number to use as the divisor.
ROUND Returns the nearest number to a number you specify, constraining the new number by a specified number of digits. ROUND(numbernum_digits) and replace numberwith the field or expression you want rounded; replacenum_digits with the number of decimal places you want to consider when rounding.
SQRT Returns the positive square root of a given number. SQRT(number) and replace number with the field or expression you want computed into a square root.

Text Functions

Function Description Use
BEGINS Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it does not.

The following markup will return true if the opportunity StageName field begins with the string “Closed”. Standard stage names “Closed Won” and “Closed Lost” would both return true.

{!BEGINS(opportunity.StageName, 'Closed')}

This function is case sensitive so be sure your compare_text value has the correct capitalization. Also, this function only works with text, not with numbers or other data types.

BEGINS(text, compare_text) and replace text, compare_text with the characters or fields you want to compare.
BR Inserts a line break in a string of text. BR()
CONTAINS Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE.

The following example checks the content of a custom text field named
Product_Type and returns “Parts” for any product with the word “part” in it. Otherwise, it returns “Service.”

{!IF(contains(opportunity.Product_Type__c, "part"), "Parts", "Service")}

This function is case sensitive so be sure your compare_text value has the correct capitalization.

CONTAINS(textcompare_text)and replace text with the text that contains the value of compare_text.
FIND Returns the position of a string within a string of text represented as a number. FIND(search_texttext[,start_num]) and replace search_textwith the string you want to find, replace textwith the field or expression you want to search, and replace start_num with the number of the character from which to start searching from left to right.
GETSESSIONID Returns the user’s session ID. GETSESSIONID()
HTMLENCODE Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as
&gt;.
{!HTMLENCODE(text)} and replace textwith the merge field or text string that contains the reserved characters.
ISPICKVAL Determines if the value of a picklist field is equal to a text literal you specify. ISPICKVAL(picklist_field,text_literal) and replace picklist_fieldwith the merge field name for the picklist; replace text_literal with the picklist value in quotes. text_literal cannot be a merge field or the result of a function.
JSENCODE Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (‘). {!JSENCODE(text)} and replace textwith the merge field or text string that contains the unsafe JavaScript characters.
JSINHTMLENCODE Encodes text and merge field values for use in JavaScript within HTML tags by inserting escape characters before unsafe JavaScript characters and replacing characters that are reserved in HTML with HTML entity equivalents. {!JSINHTMLENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.
LEFT Returns the specified number of characters from the beginning of a text string. LEFT(textnum_chars) and replacetext with the field or expression you want returned; replace num_chars with the number of characters from the left you want returned.
LEN Returns the number of characters in a specified text string.
{!LEN(Account.name)} returns the number of characters in the Account name.
LEN

counts spaces as well as characters.
{!LEN(“The Spot”)}

returns 8.

LEN(text) and replace text with the field or expression whose length you want returned.
LOWER Converts all letters in the specified text string to lowercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided. LOWER(text, [locale]) and replacetext with the field or text you wish to convert to lowercase. and locale with the optional two-character ISO language code or five-character locale code, if available. For information on supported languages, seeWhat languages does Salesforce support?.
LPAD Inserts characters you specify to the left-side of a text string.
LPAD(textpadded_length[,pad_string]) and replace the variables:

  • text is the field or expression you want to insert characters to the left of.
  • padded_length is the number of total characters in the text that will be returned.
  • pad_string is the character or characters that should be inserted. pad_string is optional and defaults to a blank space.

If the value in text is longer than pad_string,text is truncated to the size ofpadded_length.

MID Returns the specified number of characters from the middle of a text string given the starting position. MID(textstart_num,num_chars) and replace text with the field or expression to use when returning characters; replace start_num with the number of characters from the left to use as a starting position; replace num_chars with the total number of characters to return.
RIGHT Returns the specified number of characters from the end of a text string. RIGHT(textnum_chars) and replace text with the field or expression you want returned; replace num_chars with the number of characters from the right you want returned.
RPAD Inserts characters that you specify to the right-side of a text string.
RPAD(textpadded_length[, ‘pad_string‘]) and replace the variables:

  • text is the field or expression after which you want to insert characters.
  • pad_length is the number of total characters in the text string that will be returned.
  • pad_string is the character or characters that should be inserted. pad_string is optional and defaults to a blank space.

If the value in text is longer than pad_string,text is truncated to the size ofpadded_length.

SUBSTITUTE Substitutes new text for old text in a text string. SUBSTITUTE(textold_text,new_text) and replace text with the field or value for which you want to substitute values, old_text with the text you want replaced, and new_text with the text you want to replace the old_text.
TEXT Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in validation rules, formula fields, and field updates. TEXT(value) and replace value with the field or expression you want to convert to text format. Avoid using any special characters besides a decimal point (period) or minus sign (dash) in this function.
TRIM Removes the spaces and tabs from the beginning and end of a text string. TRIM(text) and replace text with the field or expression you want to trim.
UPPER Converts all letters in the specified text string to uppercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided. UPPER(text, [locale]) and replacetext with the field or expression you wish to convert to uppercase, and locale with the optional two-character ISO language code or five-character locale code, if available. For information on supported languages, seeWhat languages does Salesforce support?.
URLENCODE Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with
%20, and exclamation points are replaced with
%21

.

{!URLENCODE(text)} and replace textwith the merge field or text string that you want to encode.
VALUE Converts a text string to a number. VALUE(text) and replace text with the field or expression you want converted into a number.

Advanced Functions

Function Description Use
GETRECORDIDS Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list. {!GETRECORDIDS(object_type)} and replaceobject_type with a reference to the custom or standard object for the records you want to retrieve.
INCLUDE Returns content from an s-control snippet. Use this function to reuse common code in many s-controls. {!INCLUDE(source, [inputs])} and replace sourcewith the s-control snippet you want to reference. Replaceinputs with any information you need to pass to the snippet.
LINKTO Returns a relative URL in the form of a link (href and anchor tags) for a custom s-control or Salesforce page. {!LINKTO(labeltarget,​ id, [inputs], [no override]}​ and replace label with the text for the link,target with the URL, and id with a reference to the record. Inputs are optional and can include any additional parameters you want to add to the link. The no overrideargument is also optional and defaults to “false.” It applies to targets for standard Salesforce pages such as $Action.Account.New. Replace no override with “true” when you want to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere.
REGEX Compares a text field to a regular expression and returns TRUE if there is a match. Otherwise, it returns FALSE. A regular expression is a string used to describe a format of a string according to certain syntax rules. REGEX(textregex_text) and replace text with the text field, and regex_text with the regular expression you want to match.
REQUIRESCRIPT Returns a script tag with source for a URL you specify. Use this function when referencing the Force.com AJAX Toolkit or other JavaScript toolkits. {!REQUIRESCRIPT(url)} and replace url with the link for the script that is required.
URLFOR Returns a relative URL for an action, s-control, Visualforcepage, or a file in a static resource archive in a Visualforcepage. External websites can use absolute URLs for use in certain Visualforce components, such as
<flow:interview>.This can be used to return a reference to a file contained in astatic resource archive (such as a .zip or .jar file).
{!URLFOR(resourcepath)}

Replace resource with the name of the static resource archive expressed as a merge variable (for example,
$Resource.resourceName

), andpath with the local path to the file in the archive that you want to reference.

{!URLFOR(targetid, [inputs], [no override])} and replace target with the URL or action, s-control, or static resource merge variable, id with a reference to the record, and inputs with any optional parameters. The no override argument is also optional and defaults to “false.” It applies to targets for standard Salesforce pages such as $Action.Account.New. Replace no override with “true” when you want to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere.To access a Visualforce page, simple enter the name of your page preceeded by an “apex/.” For example, if yourVisualforce page is named
myTestPage

, you would use
{!URLFOR(“apex/myTestPage”}

.

VLOOKUP Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function. VLOOKUP(field_to_return,field_on_lookup_objectlookup_value) and replace field_to_return with the field that contains the value you want returned, field_on_lookup_object with the field on the related object that contains the value you want to match, and lookup_value with the value you want to match.

Encoding Functions

Function Description Use
HTMLENCODE Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as
&gt;.
{!HTMLENCODE(text)} and replace text with the merge field or text string that contains the reserved characters.
JSENCODE Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (‘). {!JSENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.
JSINHTMLENCODE Encodes text and merge field values for use in JavaScript within HTML tags by inserting escape characters before unsafe JavaScript characters and replacing characters that are reserved in HTML with HTML entity equivalents. {!JSINHTMLENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.
URLENCODE Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with
%20, and exclamation points are replaced with
%21

.

{!URLENCODE(text)} and replace text with the merge field or text string that you want to encode.

Posted 2012年01月5日 by gw8310 in salesforce

Tagged with , , , ,

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: