Global JS Code Not Working with Modules


I am working on a module that has a JS function added to the window scope. This function works fine in the module itself, but when the module is used in app it's no longer defined. Shouldn't it work in that case too?

How to reproduce:

  1. Create a module
  2. Add a global JS function. For example:
    function exampleFunc() { return 'example value' }
  3. Add a text with the following value Output: {{exampleFunc()}}

The above works fine inside the module

  1. Create a new app
  2. Add the previously created module
  3. The output of the function is no longer displayed

Hey @vangelov this is a known bug in Retool that we are currently working on fixing. At the moment as a workaround you can place your JS code in your Preloaded JavaScript for your Retool instance. Hope this helps!

1 Like

Ok, thank you!

Is there any update on this issue? It seems to still be happening for me.

Hey @dennis_nimblerx!

Unfortunately, no updates as of now :pensive: the team has been primarily focusing on other features.

Are you able to add your code as part of the org-level JavaScript?

Thanks for following up. I now have access internally to use org-level global JS and will use that as a workaround for now.