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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

[Power Pages]Get roles of current user use Liquid in Content Snippets

(3) ShareShare
ReportReport
Posted on by 7
I created the following code snippet to retrieve the current logged-in user's role information:
{% fetchxml userRoles %}
<fetch>
  <entity name="role">
    <attribute name="name" />
    <link-entity name="systemuserroles" from="roleid" to="roleid" link-type="inner">
      <filter>
        <condition attribute="systemuserid" operator="eq" value="{{ user.id }}" />
      </filter>
    </link-entity>
  </entity>
</fetch>
{% endfetchxml %}
{% if userRoles.results.size > 0 %}
  <ul>
  {% for role in userRoles.results %}
    <li>{{ role.name }}</li>
  {% endfor %}
  </ul>
{% else %}
  <p>No roles assigned.</p>
{% endif %}
 
However, when running the code above, it does not retrieve the roles of the current user.
Even though I have created Table Permissions for the Security Role table.
I wonder if anyone on the forum has encountered this issue like I have?
Thank you for reading my post.
Categories:
I have the same question (0)
  • Suggested answer
    Jimmy Passeti Profile Picture
    669 Most Valuable Professional on at
    Hello,
     
    The portal user is a contact in Dataverse, not an User.
    The "Role" table you are looking at is only used for Dataverse users.
    It's not the same thing, you're trying to find the Role of a user but you're passing the Id of a contact in the parameter.
     
    The Roles of a Contact (portal user) are in the “Web Roles” table
     
    Regards,
    Jimmy Passeti | Microsoft MVP
    Please mark as Verified if this answered your question!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 45 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 36

#3
Satyam Prakash Profile Picture

Satyam Prakash 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans