web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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

I have the same question (0)
  • Irena Benja Profile Picture
    414 on at

    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!

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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.

  • Suggested answer
    Irena Benja Profile Picture
    414 on at

    Hello Ravi,

    It worked, many thanks!

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    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.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans