Reuse transformers

Hello retool team!

I have a question

My transformers 'db1Transformer' and 'db2Transformer' run the same logic with different values

I'd like to reuse that logic to pass two input values, for example mergeQueries should be available globally to reuse that in different transformers

I see it this way

const ordersAmount = {{ }}.length
const clientName = {{ }}

return mergeQueries(ordersAmount, clientName)

function mergeQueries(orders, name) {
  return {
    ordersAmount: orders,
    clientName: name

Please give me examples how to implement that if it's possible
Thank you in advance!

Hey @Vlad_Shum!

It's possible to define reusable logic with preloaded JavaScript. When doing so, you can't reference the app model directly but you can create a function that is meant to accept a part of the app model as a parameter, e.g.

window.parseClientQueryData = (clientQueryData) => {
  const ordersAmount = clientQueryData.length;
  const clientName = clientQueryData;

  return {

and then reference it in your app with

{{ parseClientQueryData( }}

Does that work?