Get Logged In User details using Liquid Template in ADXStudio

As we know that Liquid Template is one of the most powerful weapon of ADXStudio.

Today in this post i would like to share the information about how to get Current Logged In User details of ADXStudio Portal.

Where It is Useful ?

You might have came across so many requirements in which you require logged in user details –
  • Perform any Operation based on Current Logged In User.
  • Hide and Show Portal Content based on Current Logged In User.
  • Perform Redirection based on Current Logged In User. For Example: If  \’User A\’ logged In on Portal, then he should be redirected to \’Page A\’ and \’User B\’ should redirected to \’Page B\’.
  • Show different Home or Landing Page after Sign In based on Current Logged In User.
  • If User A has role Role A then do this, if Role B then do that.
  • Show Logged In User Account Details.
To achieve all the above requirements you must know about the Current Logged In User after sign in on Portal.
Liquid Template is the best way to achieve the same, Here is the example of the same:

\’User\’

{% if user %}
Hello, {{ user.fullname }}!
{% else %}
Hello, anonymous user!
{% endif %}
Here, \’user\’  is an entity object.which refers to the current portal user, allowing access to all attributes of the underlying CRM contact record. If no user is signed in, this variable will be null.

\’has_role\’

{% assign is_admin = user | has_role: \'Administrators\' %}
{% if is_admin %}
User is an administrator.
{% endif %}
{% assign is_anonymous = user | has_role: \'Anonymous\' %}
{% if is_admin %}
User is an anonymous .
{% endif %}
Applied to a user object, returns true if the user belongs to the given role. Returns false if not.
By using above two features of ADXStudio, You can achieve all the above mentioned requirements.
I hope you all will get the valuable information, for any query feel free to drop me an email or comment on the post.

Published by arpitpowerguide

My name is Arpit Shrivastava, who is a Microsoft MVP in the Business Applications category. I am a Microsoft Dynamics 365 and Power Platform enthusiast person who is having a passion for researching and learning new things and acquiring immense knowledge. I am providing consistent help, support, and sharing my knowledge through various Social Media Channels along with my Personal Blog, Microsoft Community, conducting online training and attending various 365 Saturday Events worldwide and sharing the best Solutions to the readers helping them achieve their goals and objectives in Customer Relationship Space.

8 thoughts on “Get Logged In User details using Liquid Template in ADXStudio

  1. Hi Arpit, I want to get one custom field from Contact. So can I get that field directly as mentioned in this above blog? or do I need to fetch it explicitly using entities['contact'] object or FetchXML?

    Like

  2. Hi Deepashri,You don't need to write fetchxml in order to retrieve information from logged in Contact record.You can fetch custom attributes value in the same way I retrieved oob field's value.

    Like

  3. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.

    Like

  4. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: