Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to hide the sheets according to the logged in USER???

Hi All,

Will any one please help me by giving the macro code which will hide the sheet according to the USER logged in to the application?

Actually i have section access with NTNAME and i want to hide the sheet according to the user logged in and again the data also has to be restricted with respect to the user.

For me the data is getting restricted but the sheets are not getting hidden according to the USER.

I have given the conditional show statement as

"=if(VIEWING_ROLE_NAME = 'Operations Manager' or QVUSER() = 'ADMIN',1,0)"

Here the viewing role is coming from database.But one more doubt here will this VIEWING_ROLE_NAME should be a key for my data base script also. I dont know.But i dont have this key present in my data script

But for me the sheet is getting hidden, so i want some macro which will hide the sheet.

Please provide me some solution ,i need this urgent.

Thanks,

Mahasweta

1 Solution

Accepted Solutions
Not applicable
Author

Use "Conditional Show" expression to hide the sheet (Sheet Properties -> General). Example:

=UserGroup = 'Accounting'

View solution in original post

5 Replies
Not applicable
Author

Use "Conditional Show" expression to hide the sheet (Sheet Properties -> General). Example:

=UserGroup = 'Accounting'

Not applicable
Author

So one quick check please .

So this UserGroup should be one key for my case right?

Else to fetch the data it has to fetch with respect to this role as well, am i correct?

Please validate me.

Thanks,

Mahasweta

Not applicable
Author

Hi Lucia,

I am giving the condition same as you said, but when i am opening that i am not getting any data, by checking the table viewer i am seeing NTUSERNAME is not a key over there,is it not getting data due to this as since when user is logged the NTUSERNAME is the data and according to this there is no combinition data ...

Will this could be one reason ?

Please help me.

Thanks,

Mahasweta

Not applicable
Author

Add UserGroup field to your Section Access security table (the one with NTNAME) and test the expression above.

PS: Always save a copy of the document before screwing with security!

Not applicable
Author

I use this macro set a variable true or false depending of the logged user:

Sub ObtenerUsuario
set temp = ActiveDocument.GetApplication.GetProperties
'vUsuario = temp.UserName
if temp.UserName="Domain\user1" then
vUsuario=true
elseif temp.UserName="Domain\user2" then
vUsuario=true
else
vUsuario=false
end if
end sub













In Documents properties I put this macro to run on when the documents is opened. Then in Sheet properties I set the sheet to be showed when :

=$(vUsuario)


bye.