Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
newqlikie
Creator
Creator

Check if a user is allowed to see a table/listbox/...

Hi,

everybody. I have a next problem. I need to restict views to special tables/listboxes in a document.

I try do do it with "Display" "requirement" (not display always) in the document propertys. (I am not shure about the exact english translation. In German it is named "Anzeigen" -> "Bedingung")

I can read the OSUSER() and created a INLINE-tablewith the relevant users.

For Example:

The actual OSUser() is "DU\NAME3"

In my INLINE-query named "User", I added a view people who are allowed to see the tables

LOAD * INLINE [
User

DU\NAME1
DU\NAME3
DU\NAME5
DU\NAME7];

Now, how do I get theses two options together?

I tried to use following function, but this is not working:

=OSUser()=User

Thanks again for your help.

Regards

NewQlikie

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

You can check just in case.

UPPER(User) = UPPER(OSUser())

Anyway, both the previous and this work fine for me.

What it may be happening is that the data is not being reduced, so "User" field has more than one result after login. Anyway, withouth using reduction, the following piece of script should work (check syntax)

UsersConcat:

LOAD chr(39) & CONCAT(DISTINCT User, Chr(39) & ', ' & chr(39)) & chr(39) AS AllUsers

RESIDENT User;

LET vUsers = Peek('AllUsers', 0);

With that script, the conditional will look like

Match(OSUSer(), $(vUsers))

Hope this helps.

View solution in original post

8 Replies
Miguel_Angel_Baeyens

Hi,

Do first a hardcoded check with your user

OSUser() = 'DU\NAME1'


You don't need the preceding "=" sign before the conditional in the document.

Hope this helps

Not applicable

If you need to display (or not) only one chart, or two, I would use the Miguel's solution which is the easiest.

If you really want to store the authorized users in an internal table, then you'll have to use more complex expressions...

Regards,

Sébastien

newqlikie
Creator
Creator
Author

Hi,

I need to store the persons in a separate table, because I have more than 5 tables with the user-check.

First I added in each table following restriction to display, which is working:

OSUser=DU\NAME1 or OSUser=DU\NAME3 or OSUser=DU\NAME5 or OSUser=DU\NAME7 ...

The problem with this solution is, if a new person becomes the right to see the tables, I have to add that person in each table.

It will be easier, if I can add that person just in the script, so the rights will become effect after a new load of the script.

The only thing is, I do not have a clue how to set up this functionality.

Thanks again for your help.

Miguel_Angel_Baeyens

Well, at least your conditionals are working properly and you know the exact format of how domain\user is displayed. Now you can add them to the script in the same way you did (say an inline table, or even a QVD file):

Permissions:LOAD * INLINE [UserDU\NAME1DU\NAME2DU\NAME3];


According to this, you may be able to hide sheet with the following condition

User = OSUser()


If the accessing user is not listed under the field "User" the sheet will be hidden.

Hope this helps

newqlikie
Creator
Creator
Author

Hi Miguel,

thank you for your answer. I tried that already, but this is not working.

I checked, if the names in the INLINE table are exactly written, like the prompted "OSUser()" are.

It seems, that they are exacly the same, but it will not work.

Do you have any idea?

Miguel_Angel_Baeyens

You can check just in case.

UPPER(User) = UPPER(OSUser())

Anyway, both the previous and this work fine for me.

What it may be happening is that the data is not being reduced, so "User" field has more than one result after login. Anyway, withouth using reduction, the following piece of script should work (check syntax)

UsersConcat:

LOAD chr(39) & CONCAT(DISTINCT User, Chr(39) & ', ' & chr(39)) & chr(39) AS AllUsers

RESIDENT User;

LET vUsers = Peek('AllUsers', 0);

With that script, the conditional will look like

Match(OSUSer(), $(vUsers))

Hope this helps.

newqlikie
Creator
Creator
Author

Hi Miguel,

thank you very much. The Upper-Case does not work, but the variable-function is working perfectly.

Thanks again.

abhijain
Partner - Contributor III
Partner - Contributor III

Hii,Can you please provide me with an example.