How to trigger a javascript transformer to rerun

Hi,

I am wondering if we can use a javascript query to trigger a javascript transformer to run? I tried transformer.run() and transformer.trigger() in the javascript query, but they both don't work.

Thank you!

Hey doris.I, happy to help with this :blush: JS transformers can't be triggered in the same way that a JS query can. JS transformers update when their input variables update and return a value that can then be referenced in your app.

Here are a couple of suggestions for your use case:

1) You could make your JS transformer into a JS query and trigger that query.

2) You could reference transformer.value to get the return value of your JS transformer.

I hope that clears things up for you :slightly_smiling_face:

Hi @everett_smith,

Thank you for the clarification!

I'm also curious about this!

Once I convert my transformer to be a JS query, how do I trigger it to refresh every time I call a REST query?

Do I need to wrap them both in a third JS query that manually triggers the "prep" query and the REST query?

This is all related to custom authentication to generate a signature for a REST API.

Hey @mattcaruso - great question! I'm wondering if applying a success event handler to the REST query would help you to trigger the refresh needed for the JS query?

I need the JS query to run before the REST query. And I may have multiple REST queries that utilize the same authentication logic. Your suggestion is reversed, unfortunately.

What action are you wanting to trigger the transformer turned JS query?

There is a "listener query" workaround that may help here. If you set up a query set to "Query JSON with SQL" and set it up to look something like this:

SELECT * FROM {{watchedInput.value}}

you could then set this query to run on input change, any time this input changes, this query should run, so next all we would need to do is add an event handler to run your JS query. Do you think this could work for your use case?

Also, wrapping them in another JS query that manually triggers as you mentioned above could suffice.