Communication Iteration

As content designer for your financial institution, you may be required to generate statements where you need to include data of iterative nature. In Communication Cloud Service, you can use the <coms_loop> in content data to generate iterative type of rendered output in PDF format.

Transactions details to generate a bank statement.
Information regarding insured and dependents of a policy.

Note:

You can use the <comms-loop> to create iterative content to be used in tables and outside tables.

Following is the syntax that you can use:

<comms-loop><comms-data>{loop variable}</comms-data><comms-data>{Output variable}</comms-data></comms-loop>

You can create iterative content in any of the following ways:
  • Iterator type

    Iterator type iteration denotes iterating only the content information per occurrence of the dynamic data collection. For example, repeating the rows of a table and list items available within the Content.

  • Spliterator type

    Spliterator type iteration denotes iterating and splitting the Content or Layout or Document itself for every occurrence of the dynamic data collection.

Following are some examples:

Example 1 - Nested Iteration

The following illustration displays one of the nested iteration permutations wherein the SPLITERATOR setup is configured to Content and Layout and Document.

Example of Nested Iteration

Package Structure

PackageName
           DocumentName   
                 LayoutName 
                      ContentName1
                      ContentName2
Assembly Template
{
        "$$Id": "PackageName1",
        "Fields": [],
        "Documents": [
        {
        "$$Id": "DocumentName",
        "Fields": [],
        "Iteration":{
              "$$Id":"DocumentName",
              "Type":"Spliterator",
              "Path":"$.FinancialYear[*]",
        "Fields": [  
                  {
                   "Name": "Year",
                   "Path": "$.Year"
                  },
                  {
                    "Name": "FixedDepositNumber",
                    "Path": "$.FixedDepositNumber"
                  },  
                  {    
                    "Name": "FixedDepositAmount",
                    "Path":"$.FixedDepositAmount"
                  }
                ]
             },
        "Layouts": [  
              {        
                "$$Id": "LayoutName",
                "Iteration": {     
                "$$Id": "LayoutName",
                "Type": "Spliterator",    
                "Path":
        "$.FixedDeposits[*].Interests[*]",
        "Fields": [
            {
             "Name":"InterestDate",
             "Path": "$.InterestDate"
            }, 
            {  
             "Name":"InterestAmount",
             "Path": "$.InterestAmount"
            }     
           ]
          }
        }
       ]
      }
     ]
   }
Content(s)Configuration
Below is the configuration to be added for 'ContentName1' content record:
Fixed Deposit Number: <comms-data>$Data {"Id":"FixedDepositNumber", "Type":"String"}</comms-data>   FixedDepositAmount:<comms-data>$Data{"Id":"FixedDepositAmount", "Type":"Decimal", "Format":"$#,###.00"}</comms-data> 
Below is the configuration to be added for 'ContentName2' content record:
InterestDate:<comms-data>$Data {"Id":"InterestDate", "Type":"Date","Format":"MMM dd, yyyy"}</comms-data>   InterestAmount:<comms-data>$Data{"Id":"InterestAmount", "Type":"Decimal", "Format":"$#,###.00"}</comms-data>

Preview Data

{    
            "FinancialYear": [
            {    
             "Year": "2021",
             "FixedDepositNumber":
      "FD2021Jan056701",
        "FixedDepositAmount": 1000,
        "FixedDeposits": [
          {  
           "Interests": [  
                      { 
                       "InterestDate": "2021-05-31",
                       "InterestAmount": 100 
                      },
                     {
                       "InterestDate": "2021-12-31",
                       "InterestAmount": 100
                } 
              ]   
             }
            ]     
           }
         ]    
        }

Example 2 - Independent Iteration

The following illustrations displays the iterated contents next to each other:

Case 1

Example of Independent Iteration next to each other case1

Case 2

Example of Independant Iteration next to each other case 2

Case 3

Example of Independent Iteration in table case 3

Package Structure
PackageName1 
           DocumentName1
                LayoutName1
                    ContentName1
Assembly Template
{
            "$$Id": "PackageName1",
            "Fields": [],
            "Documents": [{
                "$$Id": "DocumentName1",
                "Layouts": [{
                    "$$Id": "LayoutName1",
                    "Contents": [{
                    "$$Id": "ContentName1",
                    "Iteration": {  
                    "$$Id": "ContentLoop1", 
                    "Type": "Iterator",
                    "Path": "$.FinancialYear.[*]",
                    "Fields": [{     
                       "Name": "Year",
                       "Path": "$.Year"
                 }
              ]
          } 
       }]
    }]  
}]
}

Preview Data

{   
             "FinancialYear": [{   
                 "Year": "2021"     
               },
               {
                "Year": "2022" 
               }
            ]
        }

Note:

Iterated Content will be displayed sequentially in the same line.
Content Configuration - Case1 Iterated Content will be displayed sequentially in the same line
ContentName1:
         Fixed Deposit Periods: <comms-loop><comms-data>$Data {"Id":"ContentLoop1"}</comms-data><comms-data>$Data {"Id":"Year", "Type":"String"}</comms-data></comms-loop>
Content Configuration - Case 2 Iterated Content will be displayed sequentially on a separate line
ContentName1:
         <comms-loop><comms-data>$Data {"Id":"ContentLoop1"}</comms-data>
         <comms-data>$Data {"Id":"Year", "Type":"String"}</comms-data></comms-loop>

Content Configuration - Case 3 Iterated Content will be displayed in a table

Add a 2X2 table with the following configuration:

For first row, ContentName1

<comms-loop><comms-data>$Data{"Id":"ContentLoop1"}</comms-data></comms-loop>
         <comms-data>$Data {"Id":"Year","Type":"String"}</comms-data>
         
In second row,
<comms-loop><comms-data>$Data {"Id":"ContentLoop1"}
</comms-data></comms-loop>
<comms-data>$Data{ID":"Year"'"Type":"String"}</comms-data>