Assigning app variables

I have say 10 constants that I use in my app that are presently app variables. I would like to create a table as follows:

constant name value
=========== ====
LowRecordIndicator 9
MaxDelayMessageTime 3000


Then I would like to read this table, one record at a time and assign the values to my app variables. This way I can also tune/retune the app without a new binary.

I don’t think this is possible as described above, reading records from a file and then assigning values because how set app variable is bound to the app variable name.

I know I can read records from the file one at a time and manually assign them based on a search for each app variable… using…
NUMBER(LOOKUP(FIND(outputs[“Get record collection”].records, item.Constant==“K_LAST_USED_APP_INDICATOR”),“Value”))

But it wold be a better design and no maintenance to do it purely from the records read…

Yep, you’re right, currently setting (App) variables is based directly to variable name and it cannot be dynamically set. Future might be different, but currently there’s no plan to change this. You can create a feature request to our tracker here and we’ll see if it has interest and if we can fit it into our backlog at some point:

But to your case, could it be possible to have just one App variable object that would include all those 10 constants that you’d want to change? e.g. create App variable dynamic_constants and change its type to Object and add the constants you wish as its properties (as objects also). Then you’d only need to set one App variable if your API could return an object also.

response : {
    { LowRecordIndicator : 9 }
    { MaxDelayMessageTime : 3000 }

I think this might be simpler if you change your bindings to match the new schema.

Thanks. Either method… if I change a constant, it only has an effect when they open the app. if there app is already open, they need to close it first. Is there a way to execute what is in global canvas at any time? Ie have my code execute it again? thanks.

Sure it’s possible, and Global canvas is the perfect place for it.

You can create a poller to request data from backend as often as you wish. Just add a Delay Flow function after the success output of Get record / HTTP Request Flow function (or whatever you’re using). Then from the Delay Flow function go back to the same Get record/ HTTP Request.

And, of course after the Get record/ HTTP Request you should set your app variable.

(So basically this is the same configuration as default Data variable poller)

Great thanks. Is there also a way to trigger/execute it from a button ie at my request from a page?

There is Tap component Flow function available in the marketplace. I haven’t personally tested how that works, but it sounds like it should work for you.

Other option is to add a new Receive event to your button and make its Event source Fired from “Trigger event” and connect that to the same logic as Button’s Component tap is connected to. Then use Trigger event Flow function when you want to trigger Button logic.

But as a general note, I’d consider twice if it’s necessary to trigger Button logic from elsewhere. I’d rather add the Button logic to Page level and trigger that logic from Button tap event and other places where you need it to trigger. It’s easier to see what your app logic is doing if you keep the logic visible on Page level and not hide it within Components if it’s not specifically related only to that Component.