Best practices to write reusable JS functions

I need to create a reusable function that needs to be accessible from various points within an application. I'm contemplating whether to craft a new JavaScript query specifically for this function, employ a transformer, or simply place it within the Preloaded JavaScript section under the app settings. Could you please provide guidance on the best practices for this scenario?
I checked this post but couldn't find App Actions anywhere in Retool. (I am on the Self Hosted version of Retool)

Hello @Mustafa_Saify!

I would recommend creating a JavaScript query :slightly_smiling_face:

Transformers are primarily for cleaning/formatting/sanitizing data from a DB query.

Also a 'Preloaded Javascript' would work as well. I just read the post you linked and it seems we have moved the location of Preloaded JS but I just found its new home!

On the left hand side of your app while in edit mode you should see a gear icon for 'App Settings' :gear: If you click this, 'Preloaded JS' will be the fourth option from the top, also on the left side of the screen.

Hope this helps!

Also we have a new feature in Alpha called Sync Functions for running JavaScript. Check out the forum post here to learn more about it and feel free to DM Erin to get access to test out the new product!

1 Like