Skip to main content

Notifications

Community site session details

Community site session details

Session Id : QWNl+E2F4l9l5U+4cigIxF
Power Pages - General Discussions
Answered

Query regarding retrieving current user email in Power Pages with local authentication.

Like (0) ShareShare
ReportReport
Posted on 12 Jul 2023 22:40:51 by 47

While accessing a power page (site), we do perform local Microsoft authentication. Like every user, when entering the site's URL, it goes through Single Sign-On (SSO) and routes to the power page. Is there any way to retrieve the user's email ID in power pages? In Power Apps, we can obtain the user's email using 'User().Email'. Is there a similar method to retrieve the current user in power pages?. 

 

FYI., we don't have azure subscription. 

 

I have used the below Logic, i get "Hello, anonymous user"

 

```

    {% if user %}
    Hello, {{ user.fullname | escape }}!
    {% else %}
    Hello, anonymous user!
    {% endif %}
```
Categories:
  • Fubar Profile Picture
    7,850 Super User 2025 Season 1 on 13 Jul 2023 at 22:26:15
    Re: Query regarding retrieving current user email in Power Pages with local authentication.

    If the email address is stored in Dataverse (which it would be if you are using Local Authentication or Claims mapping is configured correctly for External Identity providers then it is available via Liquid.

     

    The Liquid 'user' object is the Dataverse Contact record, when a user is logged into the portal the 'user' object will exist and all the contact fields are available (except field types that are not supported b the portal).

     

    As an example (note: in the designer it will not populate the value, only when you are logged into the site e.g. via preview, if you are not logged into the site you will get the anonymous user message)

    {% if user %}
     Hello, {{ user.fullname | escape }}!<br>
     {{ user.emailaddress1 }} 
     {% else %}
     Hello, anonymous user!
    {% endif %}

     

  • Verified answer
    Saud Ali Profile Picture
    812 Super User 2024 Season 1 on 13 Jul 2023 at 08:42:25
    Re: Query regarding retrieving current user email in Power Pages with local authentication.

    Hi @eswarcareless ,

     

    The simple answer is NO, you cannot get it in Power Pages using user object.

     

    Thanks,

    Saud

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Lucas001 Profile Picture
    2,143 Super User 2025 Season 1 on 13 Jul 2023 at 05:22:41
    Re: Query regarding retrieving current user email in Power Pages with local authentication.

    Hi @eswarcareless,

     

    unfortunately the email is not easily possible.

    You can use the id or the fullname as you already do:

     

    <p id="userName">{{ user.fullname }}</p>
    <p id="userId">{{ user.contactid }}</p>

     

    What I do to send a message is the following:

    {% assign userRoles = user.roles %}
    {% for roleItem in userRoles %}
     {% if roleItem == 'RoleWhichYouWantToCheck' %}
     <p id="message" style="display: none">YourMessage<p>
     {% endif %}
    {% endfor %}

    That way you can display a message if the user is anonymous or authenticated.

    I use that code snippet for a custom role and display a message afterwards.

     

    Hope that helps. Please mark the post as a solution if it solves your problem or consider a thumbs up when it helps.

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,769 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard