- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2016 07:19 PM
Hi ,
I am trying to check the roles of the logged in user to display a piece of HTML .
<j2:if test="$[gs.hasRole('R1') || gs.hasRole('R2') || gs.hasRole('R3')]">
<a data-toggle="collapse" href="#dropdown-lvl3">
Sample Menu Item
</a>
</j2:if>
This code is not working.. .Any idea what is the correct way to do this?
Thanks in advance
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 02:02 AM
Hi Mary,
You have used gs.hasRole in Jelly Tag, it should be used in <g:evaluate> tags. You can refer below :
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate>
var checkRole=gs.hasRole('chat_admin')||gs.hasRole('chat'); // return true if success
</g2:evaluate>
<j2:if test="$[checkRole]">
<p>Your message</p> // a piece of HTML.
</j2:if>
</j:jelly>
Thanks.
Akhil
Hit Like/Helpful/Correct, if applicable.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2016 08:03 PM
Hi Mary,
You may find below link helpful.
Re: gs.hasRole is not working in Jelly Script
Re: Need Help on Jelly Scripting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 02:02 AM
Hi Mary,
You have used gs.hasRole in Jelly Tag, it should be used in <g:evaluate> tags. You can refer below :
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate>
var checkRole=gs.hasRole('chat_admin')||gs.hasRole('chat'); // return true if success
</g2:evaluate>
<j2:if test="$[checkRole]">
<p>Your message</p> // a piece of HTML.
</j2:if>
</j:jelly>
Thanks.
Akhil
Hit Like/Helpful/Correct, if applicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 02:30 AM
Hi Akhil,
I tried this but it is not working.
I have a Dropdown with Cost Model Names. It's option should depend on the logged in Person. If User have 'cost_admin' role, he should have access to view all Cost Model in Dropdown. Else user should be able to view Choices of Cost Models only whose 'Visible' field Checkbox is true. Cost Model is a table so different Filter conditions for Different users. How to implement it?