Example: Travel Banner
    • 2 Minutes to read
    • Dark
      Light

    Example: Travel Banner

    • Dark
      Light

    Article summary

    Description

    This example demonstrates how to create InsertIf expressions that use Related Data information. 

    A travel agency wants to send out emails with banners informing customers about their booked travel. The content of the displayed banner changes depending on parameters such as Departure Station, Arrival Station, and Time Range.

    Example:

    Prerequisites

    The related data parameters must exist in your Engage system if you want to use the code from this page. Please note that you must replace the parameters in the code with the ones that your system is actually using.

    Parameters

    Here is a list of all parameters used in the example expressions. 

    Time Range

    These parameters are used to define when the banner will appear in the message. This can be set up in the content store block.

    Start date: Today is greater than or equal to the start of the range (2023-04-13)

    ecm:greaterEqual(date['Today'], ecm:toDate('2023-04-13', ecm:timeZone('Europe/Berlin')))

    End date: Today is less than or equal to the end of the range (2023-11-01)

    ecm:lessEqual(date['Today'], ecm:toDate('2023-11-01', ecm:timeZone('Europe/Berlin')))

    Information from the Related Data Table

    Outbound_DepartureStation and Outbound_ArrivalStation are columns in the related data table. The related data table is called "customermailing"

    Departure Station equals ACE

    'Outbound_DepartureStation', '==', 'ACE'

    Arrival Station equals FRA

    'Outbound_ArrivalStation', '==', 'FRA'

    Departure Station equals STR or FAO

    'Outbound_DepartureStation', 'regex', '(STR|FAO)'

    Your content

    In this case, it's a banner that will be displayed in the email message if certain conditions are met. Please note that this is an example only and that the URL and the image don't exist.

    img src=https://example.com//img/123654789/banner_620x300.jpg

    Expressions

    AND operator

    The booking for this passenger meets two conditions: 

    Departure from ACE AND Arrival at FRA

    <%InsertIf expression="${ ecm:lessEqual(date['Today'], ecm:toDate('2023-11-01', ecm:timeZone('Europe/Berlin'))) && ecm:greaterEqual(date['Today'], ecm:toDate('2023-04-13', ecm:timeZone('Europe/Berlin'))) }" id="Adbanner"%><%ForEach var="count" items="${ecx:filter(ecx:filter(ecx:related('customermailing', user.CustomAttribute['BookingID']), 'Outbound_DepartureStation', '==', 'ACE'), 'Outbound_ArrivalStation', '==', 'FRA')}" max="1"%><ahref="http://example/page"><img src="https://example.com//img/123654789/banner_620x300.jpg" border="0" width="625" height="300" alt="" title="Airport Image"  class="w100pc hauto"></a><%/ForEach%><%/InsertIf%>

    OR operator

    The booking for this passenger meets one of the two conditions: 

    Departure from ACE OR Arrival in FRA

    <%InsertIf expression="${ecm:lessEqual(date['Today'], ecm:toDate('2023-11-01', ecm:timeZone('Europe/Berlin'))) && ecm:greaterEqual(date['Today'], ecm:toDate('2023-04-13', ecm:timeZone('Europe/Berlin'))) }" id="Adbanner"%><%ForEach var="count" items="${ecx:merge(ecx:filter(ecx:related('customermailing', user.CustomAttribute['BookingID']), 'Outbound_DepartureStation', '==', 'STR'), ecx:filter(ecx:related('servicemailing', user.CustomAttribute['BookingID']), 'Outbound_ArrivalStation', '==', 'FRA'))}" max="1"%><ahref="http://example/page"><img src="https://example.com//img/123654789/banner_620x300.jpg" border="0" width="625" height="300" alt="" title="Airport Image"  class="w100pc hauto"></a><%/ForEach%><%/InsertIf%>

    Departure station only

    The booking for this passenger meets one condition:

    Departure from ACE only

    <%InsertIf expression="${ ecm:lessEqual(date['Today'], ecm:toDate('2023-11-01', ecm:timeZone('Europe/Berlin'))) && ecm:greaterEqual(date['Today'], ecm:toDate('2023-04-13', ecm:timeZone('Europe/Berlin'))) }" id="Adbanner"%><%ForEach var="count" items="${ecx:filter(ecx:related('customermailing', user.CustomAttribute['BookingID']), 'Outbound_DepartureStation', '==', 'ACE')}" max="1"%><ahref="http://example/page"><img src="https://example.com//img/123654789/banner_620x300.jpg" border="0" width="625" height="300" alt="" title="Airport Image"  class="w100pc hauto"></a><%/ForEach%><%/InsertIf%>

    Only Departure Station with Multiple Cities

    The booking for this passenger meets one of the three conditions:

    Departure from ACE OR Departure from STR OR Departure from FAO

    <%InsertIf expression="${ ecm:lessEqual(date['Today'], ecm:toDate('2023-11-01', ecm:timeZone('Europe/Berlin'))) && ecm:greaterEqual(date['Today'], ecm:toDate('2023-04-13', ecm:timeZone('Europe/Berlin'))) }" id="Adbanner"%><%ForEach var="count" items="${ecx:filter(ecx:related('customermailing', user.CustomAttribute['BookingID']), 'Outbound_DepartureStation', 'regex', '(ACE|STR|FAO)')}" max="1"%><ahref="http://example/page"><img src="https://example.com//img/123654789/banner_620x300.jpg" border="0" width="625" height="300" alt="" title="Airport Image"  class="w100pc hauto"></a><%/ForEach%><%/InsertIf%>

    Arrival Station only

    The booking for this passenger meets one condition:

    Arrival at FAO only

    <%InsertIf expression="${ ecm:lessEqual(date['Today'], ecm:toDate('2023-11-01', ecm:timeZone('Europe/Berlin'))) && ecm:greaterEqual(date['Today'], ecm:toDate('2023-04-13', ecm:timeZone('Europe/Berlin'))) }" id="Adbanner"%><%ForEach var="count" items="${ecx:filter(ecx:related('customermailing', user.CustomAttribute['BookingID']), 'Outbound_ArrivalStation', '==', 'FAO')}" max="1"%><ahref="http://example/page"><img src="https://example.com//img/123654789/banner_620x300.jpg" border="0" width="625" height="300" alt="" title="Airport Image"  class="w100pc hauto"></a><%/ForEach%><%/InsertIf%>

    Only Arrival Station with Multiple Cities

    The booking for this passenger meets one of the three conditions:

    Arrival at ACE OR  Arrival at STR OR Arrival at FAO

    <%InsertIf expression="${ ecm:lessEqual(date['Today'], ecm:toDate('2023-11-01', ecm:timeZone('Europe/Berlin'))) && ecm:greaterEqual(date['Today'], ecm:toDate('2023-04-13', ecm:timeZone('Europe/Berlin'))) }" id="Adbanner"%><%ForEach var="count" items="${ecx:filter(ecx:related('customermailing', user.CustomAttribute['BookingID']), 'Outbound_ArrivalStation', 'regex', '(FAO|STR|FRA)')}" max="1"%><ahref="http://example/page"><img src="https://example.com//img/123654789/banner_620x300.jpg" border="0" width="625" height="300" alt="" title="Airport Image"  class="w100pc hauto"></a><%/ForEach%><%/InsertIf%>


    Was this article helpful?