Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Portal - role based security in liquid language not working

(0) ShareShare
ReportReport
Posted on by

I have created a template using below language and I found this is not working:


{% if user.role_keys contains 'admin' %}

user is admin.

{% else %}

user is not admin.

{% endif %}

it doesn't recognize my admin account.

Then I tried another way to write it as

{% assign is_admin = user | role: 'admin' %}

{% if is_admin %}...

and I found it assigns every user to true value which makes it not working.

Could anyone let me know which part is going wrong?

Also, I don't find this liquid language factors documented anywhere in MS official which is very dissapointing. If anyone has any reference it will be very appreciated.

Thank you very much!

*This post is locked for comments

  • RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Portal - role based security in liquid language not working

    Thanks Ira.

    Appreciate if you could mark the auggestion as helpful and close the thread. This will also help others looking for a same issue.

  • Suggested answer
    Irena Benja Profile Picture
    414 on at
    RE: Portal - role based security in liquid language not working

    Hello Ravi,

    It worked, many thanks!

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Portal - role based security in liquid language not working

    Hi Ira,

    In order to make user.role_keys contains 'admin', you need to set the key on the web role records. Each web role record you create in crm has a field called "Key", if you put admin in that web role, it will recognize that role.

    ** it is not visible on the form, you may need to add it.

    Hope this helps.

  • Irena Benja Profile Picture
    414 on at
    RE: Portal - role based security in liquid language not working

    How did you fixed this?

    I have the same issue, initially I was using  {% if user.roles == 'Partner SuperUser' %}  but it is not working anymore ..

    Thanks in advance!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
dkrishna Profile Picture

dkrishna 6

Featured topics

Product updates

Dynamics 365 release plans