Content Block Condition

Ken83
Mega Guru

Hello Community,

        This is a rather basic issue but i'm not convinced that i'm missing something here, so much as this being an issue with the content block itself. I read → Display content block (iFrame) only to users in specific group â†� that article but, it's still not working properly for me.

I have an iFrame content block that i would like to have shown based on the user having a certain role. In my test cases, i'm using the auditor role. Here is the code that i am using...

find_real_file.png

I am on the Helsinki version. The content block is still showing regardless if i have the role or not.

1 ACCEPTED SOLUTION

Ken83
Mega Guru

Ok, so it looks like I had to take a roundabout way of getting this to work as expected. Here is what i had to write into the condition field to properly evaluate the conditions i need.



find_real_file.png


The weird part is that even though i'm getting the proper answers now, the logs are still showing incorrect values for gs.getUser().hasRole('auditor').


View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Ken,



I would make sure you're not testing with the admin user, as hasRole() will always return true for an admin. You might also add some logging to see exactly what is happening.


That crossed my mind after several failed attempts but i'm logged in as a non-admin user and it's doing the same thing. I added logs and here is what i have...


find_real_file.png



Confirmed that the user does have the role...


find_real_file.png



Checked the logs and this is what i see...


find_real_file.png


Ken83
Mega Guru

Ok, so it looks like I had to take a roundabout way of getting this to work as expected. Here is what i had to write into the condition field to properly evaluate the conditions i need.



find_real_file.png


The weird part is that even though i'm getting the proper answers now, the logs are still showing incorrect values for gs.getUser().hasRole('auditor').


Brad Tilton
ServiceNow Employee
ServiceNow Employee

Have you logged out and back in as that user? That's the only thing I can't think as you definitely shouldn't have to do a gliderecord query.