cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
lvzheng
Level: Powered On

How to get user's attribute in portal

{{user.fullname}} 

only above function work for me so far; can I access other user's attributes in portal??

I defined a field named departments in contact, the portal will display the content based on this users department

1 ACCEPTED SOLUTION

Accepted Solutions
OOlashyn
Level 8

Re: How to get user's attribute in portal

hi @lvzheng,

Yes you can access other attributes of the user the same way as from any other entity (see entity liquid object docs). All you need to know is logic name of the field. For example: field with logic name firstname can be accessed like this user.firstname; field with logic name dwc_somedata can be accessed like this - user.dwc_somedata. 

Please be aware that lookup field will be returned as Entity Reference object and optionsets will be returned as OptionSet object.

View solution in original post

6 REPLIES 6
OOlashyn
Level 8

Re: How to get user's attribute in portal

hi @lvzheng,

Yes you can access other attributes of the user the same way as from any other entity (see entity liquid object docs). All you need to know is logic name of the field. For example: field with logic name firstname can be accessed like this user.firstname; field with logic name dwc_somedata can be accessed like this - user.dwc_somedata. 

Please be aware that lookup field will be returned as Entity Reference object and optionsets will be returned as OptionSet object.

View solution in original post

lvzheng
Level: Powered On

Re: How to get user's attribute in portal

Thanks for reply

but when I try the code

{% assign current_user = entities['contact'][user.id] %}
{{current_user.cr7cc_departments}}
{% if current_user == null %}
I am empty
{%endif%}
 
it returns the "I am empty"
OOlashyn
Level 8

Re: How to get user's attribute in portal

Hi @lvzheng,

You don't need to retrieve user as a contact in a separate request. User object is a special one - it already contains attributes from contact record and additional details like roles (check out this docs for more info). You should be able to retrieve data from your custom field using just user.cr7cc_departments call.

Pbv
Level: Power Up

Re: How to get user's attribute in portal

Hi,

 

I have the same problem but in my case I am looking for the email id of the user who currently logged in.

 

When tried with user.internalemailaddress the result is empty.   Appreciate your reply.

 

Thanks

OOlashyn
Level 8

Re: How to get user's attribute in portal

Hi @Pbv ,

Portal users are contacts in CRM. So to get the contact email address you need to use emailaddress1 field.

Pbv
Level: Power Up

Re: How to get user's attribute in portal

@OOlashyn- Excellent that works perfectly.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (4,264)