Global constants

Don’t know if this is general knowledge but I’ll post anyway.

I had numerous Show_If statements for Actions that used LOOKUP to a table to check the status of users to determine whether each of 6 actions would be shown, or not. The statements became quite lengthy and therefore quite complicated.

While taking a break from the App I thought “wouldn’t it be nice if AppSheet had a way of storing Global Constants”, like other programming languages. Then it came to me…

Could I use USERSETTINGS() to store GLOBAL CONSTANTS that I could then make reference to without having to interrogate the table each time a new form was shown and therefore which Actions to Show? The added difficulty being that the CONSTANTS would be based on the USER…

Anyway, I set up 2 USERSETTINGS(). Each would LOOKUP the table for the 2 values from the table and store them in the USERSETTINGS table.

Each had a Formula that looked up each value and stored it. Such as below…

The Formula includes a check in case the table returns nothing.

Then in my Action Show_If Statements I can use the values of [Admin Role] and [SCPTD Role] without having to call a LOOKUP each time.

Hope this helps :slight_smile:

8 Likes

Thank you very much @Steve_Fuller for sharing this useful Tip.
It’s always good to reduce expressions. And in fact - the User-Role doesn’t change often, so it’s a good point to store it in the USERSETTINGS.

1 Like