Skip to main content
Skip table of contents

count

Counts the number of characters, if the value is text/html. Counts the number of items within a Collection, if the value is a Collection. Places the result into a new variable. While a Collection's number of items can be easily accessed through the Collection value's size() method, this command offers a safer way of doing this as it doesn't cause errors should the target variable have a null value, or not actually hold a Collection value.

Attributes

var

Required

Value type

EL-evaluated

Yes

String

No

Defines the name of the variable that will receive the number of items as a Number value.

value

Required

Value type

EL-evaluated

Yes

Any

Yes

The resolved value of this attribute can either be the Collection whose items are counted, or text/html whose characters are counted. However, any kind of value is accepted - even null. The result of the count for any other value will always be 1, whilenull results in 0.

Examples

One use for the count command is to find out the number of records a Salesforce data retrieval command managed to retrieve:

CODE
<query var="opportunities" select="SELECT Id, Name FROM Opportunity"><count var="thisManyOppos" value="${opportunities}">
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.