Hi! I need some help figuring out how to reference my external Javascript. I would like to create my own custom Javascript library, and I wrote some stuff up, put it in a test.js file, made it publicly accessible, and used the 3 dots to add my script to a very simple app.
The only thing in my script is a variable definition, and the only thing in my test app is a javascript query that references my variable. But, the variable is red, not green, as if Retool can't resolve the reference.
I read the following link, but couldn't make heads or tails out of what I need to do. It seems the others are using public domain libraries, and I want to use my own stuff. So, I can't tell if a "library" is something extra or if a regular old Javascript file will work.
Oh, BTW, I had been using the Organization-level Pre-loaded Javascript, but as I continued developing, the tiny editor became more and more of a problem. Also, if a single syntax error was made, it seemed to make the entire script inaccessible, and so it will be easier for me to keep my stuff clean if I can develop my own external scripts.
Ok. So, I spent a very long time trying to figure out what the format for the Javascript library was supposed to look like. Never could figure it out.
But, I did figure out how I could solve my real problem. My real problem is having two dashboards that need to share code. I tried putting it the Preloaded Javascript library, which would have worked, but it became increasingly difficult to maintain as it grew. A single typo seemed to break the whole thing, with no debug output I could find to help drill down where the problem was. My only solution was to comment out large portions and gradually uncomment parts until it broke. Then, I knew what section to look at. Too time consuming.
Libraries, I just could not get working.
But, modules. That I could do. I didn't think of it at first, because I thought of a module as being a display piece, as in it would be the header part of the app or something, but I really just needed inputs and outputs. In the end, I ended up having the module be a sidebar, that way I could enforce the selection options that were being provided as inputs, so I'm not sure if it would work for pure code encapsulation without the visual components. But, for me, it provides a way to write code once and use it twice, and that's what I need.