Dynamic value for Module query input value


there isn't a way to dynamically select this function. using JS you can change the value, but it's only temporary and it resets after the JS completes. you also can't select a variable to hold the info, the dropdown only lists queries. is there another way to do this that i'm missing? function pointer maybe but input has to be a string, so I don't think that'll work too well?

from the parent app mymodule.inputName = "test" is temporary, the value of .inputName reverts back after the JS block completes so future use of the input will still get the original value not the new one ("test").

from the module (editing module) you are able to do moduleContainer.inputName = "test" and the change WILL persist after the JS block completes, so future queries or accesses will have the new value

Hey @bobthebear, I'm happy to create a FR for this! :slightly_smiling_face:
But to best assist you, could you share a bit of the use case? I want to provide as much context to the Engineering Team as possible.

Hey Paulo, thanks for the help. There's 2 places I could use this. One is like in the below picture, where I just want to select different queries based on something like the user or user_group.
here's what I tried from a query inside the module. you can see 2 consecutive runs output the same thing. only the first before: should be defaultAvatar, all other 3 lines should say newQuery.

I was also trying to have the parent contain the logic for selecting the correct 'avatar query' to set the module input as. It'd be kinda handy when the query passed can fail and you need to use a different source as a fallback, so in the Failure handler you'd just set the input query to something different.... or if you use a global isDebug flag to use different queries for different sources. I accidently blew through a bunch of calls to a paid api :crazy_face: :cry: so now my global flag saves me and my petty wallet :joy:


//Run JS Code (query)
//from the parent app
console.log(myModule1.getAvatarQuery) //this is old value
myModule1.getAvatarQuery = isDebug.value? "TESTDATA" : "generateAvatar";
console.log(myModule1.getAvatarQuery) //this is new value
return; //after this is where any change to .getAvatarQuery is lost.  any subsequent calls to this query will produce the same results


REST Resource Query 
-passed as value to 'myModule1.getAvatarQuery` for module input
onFailure: {{ myModule1.getAvatarQuery = "getDefaultAvatar" }} 

here I just wanted to use a different query if the one passed to the input failed. both queries reside in the parent, so I can either make 2 inputs for the module and let the module handle the logic for selecting which to use or I could dynamically set the query used as an input. It's not really the job of the module to handle logic for using the correct input, for me this module should just be concerned about using the input and the app should worry about picking the right query. just using 2 inputs here would work and isn't a big deal, but things can get out of hand very quickly creating a ton of unused input variables and cluttered code at best and wasted memory at worst imo

Hey @bobthebear, I am sorry about your wallet, those API calls can add up! :pensive::moneybag:
There is currently a FR to avoid running queries/stop them when are testing or making changes to the UI. I'll tag you on that topic for you to get a notification the moment we get any updates. On the other hand, thank you for sharing more details! Now that I have more context, I created a FR and included the use cases you shared.

1 Like