Control structures
Prisma Campaigns provides the IF
construct and the FOR
loop as ways to evaluate boolean fields or to iterate over multi-valued data, respectively. Both mechanisms can be utilized through dynamic expressions to personalize content based on customer or system data.
To leverage customer or system data, use curly brackets and dot notation. Some examples include (but are not limited to)
{{customer.sex}}
,{{customer.age}}
, and{{system.current-data}}
.
Although IF
and FOR
follow the same structure as in most programming languages, refer to the sections below for more details.
Conditional statement: IF
The IF
statement can be used to generate content depending on a conditional value, most often from a customer data field such as {{customer.age}}
or {{customer.sex}}
. For example, the following code block will print Mr. or Mrs. if the customer is male or female followed by his or her name, respectively. If the customer is missing the information on the sex field, only the name will appear in the message after the word Dear:
{{IF customer.sex = "M" THEN
"Mr. "
ELSE IF customer.sex = "F" THEN
"Mrs. "
ELSE
"Dear "
END}}
{{customer.name}}
In the above example, the ELSE
clause is optional. Also, the customer data fields do not need to be enclosed in curly brackets in this case since they are already within a evaluation block.
FOR loop
The FOR
loop allows to iterate over product lists, insurance policies, or any other customer data with a cardinality greater than 1.
<ul>
{{FOR product in customer.products
<li>product</li>
END}}
</ul>
In this case, the loop builds an unordered list (ul) with as many items (li) as products are found in customer.products
.
On this page