CSV Doc from Template issues

Certified Senior Developer

I have a csv template which is expecting few fields(could be 100 columns).

First i created a dummy template to see if this even works and i am facing some challenges here, need some help in understanding what i did wrong.

Below CSV has the data returned however not in expected format. These are supposed to print in 3 different rows but not in same row.

Did a!foreach for each column to return its value and saved in respective variables...

my actual template:

a!localVariables(
  local!data: a!queryEntity(
    entity: cons!TST_DSE_TEST,
    query: a!query(
      filter: {
        a!queryFilter(
          field: "createdOn",
          operator: ">=",
          value: fn!datetime(2023, 7, 1, 7, 2, 5, 0)
        ),
        a!queryFilter(
          field: "createdOn",
          operator: "<=",
          value: fn!datetime(2023, 8, 1, 7, 2, 5, 0)
        )
      },
      pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 3)
    ),
    
  ).data,
  /*Did a!foreach for each column to return its value and saved in respective variables*/
  a!forEach(
    items: local!data,
    expression: joinarray(
      if(
        isnull(fv!item.columnD),
        "N/A",
        fv!item.columnD
      ),
      char(13) & char(10)
    )
  )
)

  Discussion posts and replies are publicly visible