For Fetch

This token type is used to list content for each result of a FetchXml query. The FetchXml query can include conditions to link from the source record, to enable listing content for each related record

The token is composed of 3 main parts

  1. a for fetch token containing a fetchxml query
  2. an end for fetch token closing off the content
  3. content between the above tokens which will be repeated for each result of the fetchxml query

The example below is for a content template with source type account and outputs a table with rows for each active case where the account is the customer

Note columns from the source entity can be used in the fetchxml query to filter results (in this case accountid). Field tokens in the content will then be replaced from each result of the query, unlike field tokens outside of the token which are replaced by the main source record. There is no need to include attribute nodes in the fetchxml query as the solution manages the required attributes based on tokens in the content

<table>
    <thead>
        <tr>
            <th>Ticket #</th>
            <th>Title</th>
        </tr>
    </thead>
    <tbody>
        [forfetch <fetch>
    <entity name=”incident”>
        <attribute name=”incidentid” />
        <filter type=”and”>
            <condition attribute=”customerid” operator=”eq” value=”[accountid]” />
        </filter>
    </entity>
</fetch>]
        <tr>
            <td>
                [ticketnumber]
            </td>
            <td>
                [title]
            </td>
        </tr>
        [endforfetch]
    </tbody>
</table>