Security Filter User Table

Hello great big world. Iโ€™m running into a problem. I created a user table to assign access. This particular table has e-mail, district, and location. For district and location I use an enumlist so I can assign more then one thing to that user. Iโ€™d like to use that to establish my security filter, but Iโ€™m having a problem figuring out the right syntax to make that occur.

I know that if I had built this allowing the user to select it in user settings, this would be easy. It would look like
in([location],usersettings(location))
but alas I need to assign users rights instead of them just selecting it.
So I built it to look like this
in([location],list(lookup(useremail(),โ€œusertableโ€,โ€œe-mailโ€,โ€œlocationโ€)))

I get no true values when I do that, so Iโ€™m not sure what I did wrong here. Iโ€™m guessing itโ€™s the list/lookup function, but I donโ€™t know what else I should use.

Please let me know your thoughts

Solved Solved
0 7 474
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Try:

in([location],split(lookup(useremail(),โ€œusertableโ€,โ€œe-mailโ€,โ€œlocationโ€), " , "))

View solution in original post

7 REPLIES 7

The expression appears like it should work fine. You donโ€™t need to LIST() wrapper if the location column is already an enumlist, but it also shouldnโ€™t affect anything in this case.

Put the LOOKUP() expression in some column somewhere and test it to make sure it is returning the correct list.

The table that youโ€™re setting the security filter for also has a โ€œlocationโ€ column?

Are you sure that your logged-in email has an entry in the user table?

Yep, tried the lookup function in a virtual column and it returned the two locations I expected. So thatโ€™s working fine.

Yes, the table that I am setting the location filter for also has a column named location.

And yes, the logged in email is also in my table, I can see that works too because my lookup function is working.

Iโ€™m using the List wrapper because when I tried it as just a lookup it didnโ€™t allow for multiple possibilities. For example I have two locations, Camden and Smyrna. If I only choose one site then the function works fine with just a look up because it can just match the single location Camden=Camden. I put the list function back in there to try to have a list of possibilities, but it seems that when I have multiple sites, ability to select Camden and Smyrna, the system is returning a false because I donโ€™t have Camden and Smyrna as a site in my record. Should there be another function or combination of functions that I should use to bring back a list?

Iโ€™ve gone through just now and changed the column name to โ€œsiteโ€ instead of โ€œlocationโ€ to see if there was some odd conflict, but still no luck. All my records turn back as negative. I think Iโ€™m not returning a usable list to the function, but Iโ€™m not sure of another good way to do it.

Steve
Platinum 4
Platinum 4

Try:

in([location],split(lookup(useremail(),โ€œusertableโ€,โ€œe-mailโ€,โ€œlocationโ€), " , "))

Yep, that did it. Thank you

@steve Can you explain why the split() is needed? Is lookup() not able to return a list value?

LOOKUP() is basically the same than ANY(SELECT()) where the result is one value. Even if itโ€™s EnumList, itโ€™s just a string and you need to use SPLIT so it will be list again.

Ahh, gotcha!

Top Labels in this Space