I try to make a table editable if is is allowed by the Device ID.
Hence, I made the table 'Read only' and entered a formula in it like:
_____________________________
SWITCH(CONTEXT("Device"),
"1234567a-32ae-12d2-123e-369a874d8feb", "UPDATES_ONLY",
"cb1bb23b-45b6-7c8c-901d-2e3eeeeeee54", "ALL_CHANGES",
"READ_ONLY"
)
_____________________________
This does not work.
What am I doing wrong?
P.S. I have written permission from appSheet support to use the DeviceID like this.
It is not a violation of the public license.
Yes, I am aware that the DeviceID may change at any time and that it is not very secure, but that is no problem in my case.
Solved! Go to Solution.
I renamed the table "UserSettings" to "UserInfo" and now it works.
Should work, no idea why it doesn't
You should report this to support
I have expanded the statement, but this gives a hard error.
SWITCH(LOOKUP(CONTEXT("Device"), USERSETTINGS, DeviceID, Role), "God" , "ALL_CHANGES", "Contributer" , "ADDS_ONLY", "Admin" , "ADDS_AND_UPDATES", "READ_ONLY" ) |
SWITCH function is used incorrectly: Inputs to SWITCH() must be an initial expression, one or more value-result pairs, and a default result.
I do not understand why this gives me an error.
The first line, the opening of the SWITCH statement, is followed by a LOOKUP statement that should return a single value. Based upon the DeviceID, a value like 'God', 'Contributer' etc. will be returned. That would feed the Switch (I hope) and result the needed rights.
Why do I get an error in this statement?
I think the error returned is more due to LOOKUP expression rather than SWITCH.
Can you try:
SWITCH(LOOKUP(CONTEXT("Device"), "USERSETTINGS", "DeviceID", "Role"),
"God" , "ALL_CHANGES",
"Contributer" , "ADDS_ONLY",
"Admin" , "ADDS_AND_UPDATES",
"READ_ONLY"
)
USERSETTINGS is a reserved word ๐
USERSETTINGS() - AppSheet Help
I renamed the table "UserSettings" to "UserInfo" and now it works.
User | Count |
---|---|
33 | |
29 | |
29 | |
20 | |
18 |