This suggests to me that additionalScope, which is sort of function-like thing, is not really a first class function. And I know that real first class functions which live inside "Preloaded JS" cannot call all kinds of Retool things such as JS queries. For example it would be impossible for me to transform lcliz_orchestrator.trigger() into a real function lcliz_orchestrator() because inside it does a lot of complicated work calling all kinds of Retoolisms:
So....I don't know if what I want to do is impossible, or if there is another way or trick.
You can use a transformer instead and call it like this in the mapped value
{{ transformer1.data[i] }}
You will need to modify the code to force the transformer to return an array.
something like:
let tableData = {{ table1.data }}
let newArray = []
for (let i = 0; i < tableData.length; i++ {
// your code here
tableData[i].description
newArray.push()
}
return newArray
Yep. I tried that but I can't call my localize "function" inside the transformer. The transformer seems to have the same limitation as the mapped value. A box where javascript can be executed but with serious constraints.
I can probably unroll all the code inside my localize function and inline it and make it work. But that's just so ridiculous. I made a javascript function that takes additionScope precisely so I could reuse the code in several places.
A workaround will be to modify your query to run at the beginning and be able to populate your table or make another separate query/transformer specific for that table
Yeah that's what I was trying to do in the transformer. Both transformers and success handlers are ways of chaining together long pipelines of queries. I find that "pattern" to be OK but not great. I end up with a lot of stuff like this:
A -> B -> C -> D.data (is finally displayed in some UI).
Then somewhere else I have the same pattern:
J -> K -> L -> M.data
But suppose B and K are basically the same logic? I often find myself with this sort of duplicated logic because the inputs and outputs are different; even though the inner logic is the same.
I was trying break this pattern by using additionalScope but now I see there are all sorts of other restrictions that fight against that.
I wanted to follow up here in case you missed Evan's most recent message - if you have any screenshots of your setup to share, I can definitely pass those along to our product team. Thanks in advance!
Screen shots are a lot of trouble. I'm not even sure WHAT screenshots would matter here.
In any case the bigger question is why is "additionalScope" available in some places and not others? I find there are many cases where I could reuse some component or logic if only I could pass in parameters and sometimes that facility is there and sometimes it is not and in that case duplication is the only solution. Why?
I was notified that you attended office hours today, but please let us know if you have any follow-up questions moving forward! To recap what was shared there:
you define the additionalScope variable from your JS query or wherever you're triggering the query from! then, in your target query, you'll need to use the variable you just defined
Screenshots do seem like a pain, until you learn some handy keyboard shortcuts. Like on macos, i do option command shift 4 and can take any size screenshot and then paste it straight into here. takes like 3 seconds. i'm sure there is some equivalent on pc