Saturday 21 January 2017

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.

8 comments:

  1. How to assign user name to a variable?

    ReplyDelete
  2. 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?

    ReplyDelete
  3. 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.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. That is really nice to hear. thank you for the update and good luck. Shortfill Vape Juice

    ReplyDelete
  6. how to get lookup value in portal page

    ReplyDelete
  7. 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.

    ReplyDelete
  8. 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.

    ReplyDelete

Blogger Widgets