Usersettings expression in a slice row filter

Trying to use a value from the Usersettings () within a slice row filter condition.

The data table has corresponding company reference [COMPANYLOG] and I thought it was as simple as:

[COMPANYLOG]=USERSETTINGS(Company)

I have checked I have values in the data table and Usersetting that match but not coming through - am doing this correct?

0 6 1,191
6 REPLIES 6

Try to use USERSETTINGS(โ€œCompanyโ€) if that would help.

Thanks You very much

Steve
Platinum 4
Platinum 4

In what way is it โ€œnot coming throughโ€? Some rows youโ€™d expect to appear arenโ€™t? None of the rows youโ€™d expect appear? Rows you donโ€™t expect do appear?

At the very least, because of the way the is-equal-to? operator (=) works in AppSheet, if the left-hand argument ([COMPANYLOG], in your case) is blank, the expression will be TRUE regardless what the right-hand argument (USERSETTINGS(Company)) is. This might result in the occurrence of unexpected rows in your slice if [COMPANYLOG] is ever blank.

Thanks - they were blank - no rows coming through. I think then discovered the usersettings werenโ€™t getting updated and saved unless I went into the settings menu view and โ€œclickedโ€ save.

Which leads me to ask a question - when a user logs in for the first time, does the usersettings pick up an initial value expression or do you actually have to go into the setting menu and click โ€œsaveโ€ to create the record?

I wanted the usersettings to default to values in my โ€œuserโ€ table - such as which company they represent and what role they have. I then use this info in the slice row filter to allow:

  1. any user to see their own data
  2. any manager representing a company to see all users data from that company
  3. any user with โ€œAdminโ€ rights to see all data

I also have a filter to only bring up the last 7 days, as well as only โ€œActiveโ€ flag lines.

The filter I am using is as below - is this the best way to control my data?

and( [Date]>Today()-7,
OR([Useremail]=Useremail(),
AND([COMPANYLOG]=USERSETTINGS(โ€œCompanyโ€) , USERSETTINGS(โ€œRoleโ€) = โ€œManagerโ€),
USERSETTINGS(โ€œRoleโ€)= โ€œADMINโ€),
[STATUS]=โ€œACTIVEโ€)

To get around this not working i then used lookup() function below - is this suitable?
Seems to work on mobile device fine. My next thought was to setup virtual columns to pull in the user credentials to use in the same expression instead of lookup() function - would that work and is it a better way to handle data?

and( [Date]>Today()-7,
OR([Useremail]=Useremail(),
AND([COMPANYLOG]= LOOKUP(Useremail(),โ€œUSERSโ€,โ€œUSER EMAILโ€,โ€œCOMPANYโ€), LOOKUP(Useremail(),โ€œUSERSโ€,โ€œUSER EMAILโ€,โ€œROLEโ€) = โ€œMANAGERโ€),
LOOKUP(Useremail(),โ€œUSERSโ€,โ€œUSER EMAILโ€,โ€œROLEโ€) = โ€œADMINโ€),
[STATUS]=โ€œACTIVEโ€)

Thanks in advance if anyone can give some guidance and apologyโ€™s for the long questions.
Cheers

Did you ever get any answers or figure it out?

Top Labels in this Space