The function ecm:countMapElements returns the number of elements inside a map or -1 when the map is null. The value returned is an integer data type.

To convert the integer into a Boolean data type, compare the result of this function with the operator greater than (>) and the value zero (0). This is often used in combination with other functions to generate a true/false result for use in personalization rules and selection criteria.

Example

A related data set named ​Purchases contains all customer purchases. The key for the related data set is the customer ID. In these examples, the related data set is linked to an attribute. The syntax for the parameter is different for unlinked related data sets (see Function Syntax and Formatting​).

The related data set ​Purchases has a column called ​Offers. This column contains all offers to which customers responded with a purchase.

The customer IDs are also saved in the recipient attributes.

A segment sends a message to customers who have previously responded to an offer (of any kind). The expression used as criteria for the selection is constructed as follows:

${ecm:countMapElements(user.RelatedAttribute['Purchases']['Offers'])> 0}
CODE

In this example, the function ecm:countMapElements counts the number of offers for each customer ID and returns an integer. When this integer is compared with the operator greater than (>) and the value 0, it returns a Boolean data type. Any value greater than zero will return ​True, which satisfies the selection criteria for sending the message.

Structure​

ecm:countMapElements(map)

Parameters​

Parameter

Description

map

Specifies the target to be counted.