Use the DeviceID to make a table editable

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 Solved
1 4 188
  • UX
1 ACCEPTED SOLUTION

I renamed the table "UserSettings" to "UserInfo" and now it works.

View solution in original post

4 REPLIES 4

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?

Aurelien
Google Developer Expert
Google Developer Expert

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"
      )

Aurelien_0-1700834902005.png

USERSETTINGS is a reserved word ๐Ÿ™‚

USERSETTINGS() - AppSheet Help

 

I renamed the table "UserSettings" to "UserInfo" and now it works.

Top Labels in this Space