Is it possible to change a Quick Edit Column to non-edit depending on User Role

It would be good to know if a quick edit column can be changed to non edit column depending on User Role. For example administrators can Edit and for others (non administrators) Edits are not allowable.

0 18 804
18 REPLIES 18

I believe that is possible by including an expression within the Editable_If property of the column definition.

Steve
Platinum 4
Platinum 4

Seems like it would be easy enough to test. Have you tried?

When you allow updates and have quick edit colums, all colums can be editabe no matter if you have this expression in Editable If or Not :

If you removed the Updates from Updates Allowed โ€ฆ

This messages displays whe you save the app.
QuickEdit columns have been removed from view โ€˜Racing Days_Detailโ€™ because the data source does not allow updates.

Just now seeing this but wanted to confirm I am seeing the same behavior. Column remains editable no matter the setting of USERROLE() - at least in the Editor. I think this is a bug.

Thank you for reporting, I am not able to repro this behavior. I just want to verify, when you say โ€œat least in the Editorโ€ do you mean by changing the email in the app preview (โ€œPreview App asโ€) or by logging in to the editor in that same app with a user that has Role=โ€œUserโ€?

Iโ€™ve verified this to work as expected with the latter, as well as logged in in the app (a user that does not have role โ€œAdminโ€ will not be able to edit the column). I am however seeing a bug with the preview app functionality when it comes to the USERROLE value, I will look into this.

To clarify, we are setting the Editable _If to the expression:

USERROLE() = "Admin"

The column is then set in a Detail View as as QuickEdit column.

Then what I personally am doing, is changing the Role in the Users list for my
AppCreator email from โ€œAdminโ€ to โ€œUserโ€. No matter which setting I have, the column IS editable.

If I set other criteria in the Editable_If, the column being editable or not works as expected.

Thank you John for the extra context, when you verify with role โ€œUserโ€ are you doing this in the emulator by changing the value of โ€œPreview App asโ€ to an email that has the role set to โ€œUserโ€? Or how are you switching between users to see the different outcomes after you change their roles?

I am not changing the โ€œPreview App asโ€ at all. I am only switching the Role in the Users white list as shown in the image below.

Would you mind contacting support so I can further debug this with your app? It can be assigned to me and Iโ€™ll look into it.

I still cannot repro, the Editable_If condition works as expected with USERROLE on my end.

Thanks,
Maria

Before submitting anything, I wanted to take the time to play more with a test app to understand whatโ€™s going on. Hereโ€™s what I figured out.

  1. The App Creator account is ALWAYS and Admin. Even if I list the email address as a white-listed user, changing the Role setting has no impact.

  2. When running from the editor and testing with โ€œPreview Asโ€ I think the editor still refers to the App Creator account for USERROLE() (note: Iโ€™m pretty sure it does for USEREMAIL() as well)

  3. When trying to run browser versions of the app on the same machine, I still had issues getting a test Google account to be the logged in Google user. I havenโ€™t played with this much so I donโ€™t know if I am just missing something. I think Google tries to allow only a single logged in user? But then this means you canโ€™t have the editor open AND a browser version of the app on the same machine to easily test switching of the Role settings.

  4. I finally was able to successfully test by running the app on my mobile device where I could easily switch between the users - App Creator and a test user - while switching the Role settings from my Desktop. Everything worked as expected this way.

So the big question is, what should we expect when we use the โ€œPreview Asโ€ option in the editor?

Should USERROLE() and USEREMAIL() take on the persona of the โ€œPreview Asโ€ user?

When I use Preview App As, USEREMAIL() provides the preview-as email address. I donโ€™t have a readily-available app to test USERROLE().

I would expect the browser version of the app to use the configured app userโ€™s role.

Note that the browser app is unaware of the app editor and app emulator, and that the browser app uses only the saved app configuration, not the in-editor configuration like the app emulator does,

In order to test multiple logins for my apps, I actually have multiple logins active on my (Chromebook) laptop that I switch between.

Ideally, yes, but Iโ€™m not confident thatโ€™s implemented.

Yes correct, I should have clarified, itโ€™s not 100% across the app. For instance, Slices apparently will be based on the App Creator email address. This creates a mix of results and unexpected behavior within the app if a developer is not aware of it.

As an example below is a User table, emulator with a NON-App Creator as โ€œPreview Asโ€ BUT the CurrentUser slice reflects the row of the App Creator - not the correct โ€œPreview Asโ€ user.

Users Table

Emulator with โ€œjohnbaer510@gmail.comโ€ as "Preview As"

CurrentUser Slice where USEREMAIL() = [Email] - AFTER - โ€œPreview Asโ€ is set

So how do you do this? I am finding that if I login into a test user Google account and launch the app in the browser, when I go back to the emulator to try testing setting changes I am logged out of the emulator. I am pretty sure this is because the Google login is being persisted between browser tabs. When I am logged out and taken to the โ€œmainโ€ AppSheet page, it reflects the account of the test user I logged into the app with.

Is there some some setting the prevents Google login from being persisted across the browser tabs?

Itโ€™s a feature of Chrome OS. I can login to multiple users at a time and switch between their desktops. Itโ€™s not the same as being logged into several accounts within the same browser.

UPDATE: I have found today, that if I follow a certain order of steps. I CAN test the USERROLE() function, as it relates to this post, within the emulator.

The steps are as follows:

  1. Set the Role settings for my test user in the Editorโ€™s Users list.
  2. Refresh the BROWSER page (not a Sync - refresh the entire page). The App Creator will be reset as the โ€œPreview Asโ€ user by default after this refresh.
  3. Now set the โ€œPreview Asโ€ user and test.

After following the steps above I found that using USERROLE() in the Editiable_If of a QuickEdit field works as expected consistently within the emulator.

Thank you for all the follow up investigation on this issue. I was out for the holidaysโ€ฆ Iโ€™m glad you were able to test the function correctly.

However, while investigating on my end, I did see an edge case where USERROLE() does not work as expected. If you update a Userโ€™s role and do not refresh the editor (as you mention on your steps) and also if you input the email of a user that does not exist. Weโ€™re working on fixing both so that the experience is always consistent with that the creator expects to see.

Steve
Platinum 4
Platinum 4

Escalated.

Iโ€™m not a expert, just make a course of Appsheet and I learn

VISTA SI USU ESTร EN NUESTRA TABLA

COUNT(FILTER(โ€œUSUARIOSโ€,([CORREO]=USEREMAIL())))<>0

BLOQUEAR VISTAS SIN HACER CAMBIOS, Sร“LO LO PUEDEN VER LOS USU REGISTRADOS PERO NO CAMBIAR

AND(COUNT(FILTER(โ€œUSUARIOSโ€,([CORREO]=USEREMAIL())))<>0,LOOKUP(USEREMAIL(),โ€œUSUARIOSโ€,โ€œCORREOโ€,โ€œTIPO DE USUARIOโ€)=โ€œADMINโ€)

CAMBIOS EN DATOS/TABLA-ACTUALIZACIONES

PARA QUE ADMIN PUEDA HACER TODOS LOS CAMBIOS Y USU PUEDA AGREGAR / ACTUALIZAR CAMBIOS

if(

LOOKUP(USEREMAIL(),โ€œUSUARIOSโ€,โ€œCORREOโ€,โ€œTIPO DE USUARIOโ€)=โ€œADMINโ€,

โ€œALL_CHANGESโ€,

if(

LOOKUP(USEREMAIL(),โ€œUSUARIOSโ€,โ€œCORREOโ€,โ€œTIPO DE USUARIOโ€)=โ€œVENTASโ€,

โ€œADDS_AND_UPDATESโ€,โ€œREAD_ONLYโ€))

Try Sara

Top Labels in this Space