Apply transformer for each row in table - adding new column

Hi,
How to aplly transformer for each column in table.
For instance:
Coulmn A = 10.
New column B = Column A + 5

I know that I can do it directly from mapper saying {{currentRow + 5}}.

But I have more complicated math and would like to do it within transformer and call transformer in mapper like {{transformer1.value}}

But how can I call ""currentRow" within transformer itself?

Regards,

Hi Here is an example where I am using a transformer to add a formatted preview to each object in a collection.

// format message for preview
let nl = "\n";
let sp = " - ";

data.forEach(r => {

  var days =  [r.d1, r.d2, r.d3, r.d4, r.d5, r.d6, r.d7];
  for (let day of days) {
    let overview = "";
    if (day) {
      if (day.status) overview += day.status; 
      if (day.status_info) overview += sp + day.status_info; 

      if (day.message) {
        for (let m of day.message) {
          overview += nl + "id" + sp + m.id + nl
                + "sequence" + sp + m.sequence   + nl
                + "text" + sp + m.text   + nl
                + "link" + sp + m.link   + nl
                + "image_url" + sp + m.image_url; 
        }
      }

    } else {
      day = {};
    }
    day.overview = overview;


  }
  return r;
})

return data;
2 Likes

Hey! I've created a simple example, but it should work for more complicated math. You just need to return an Array from the JS Transformer and then we can access each specific row's information with {{ transformer1.value[i] }}.





Here we are simply adding 100 to the id of every row in the table. But more complicated manipulation of the data should work in the exact same way!