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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Obtain logged in user ...
Power Pages
Answered

Obtain logged in user attributes

(0) ShareShare
ReportReport
Posted on by 159

Hi forum,

 

I have a use case that requires the logged in user's time zone, locale (language/country), currency and email address.

 

I know that Portal Users are based on Dataverse Contact records and that Liquid has the user object.

 

Other than email address, do the other aforementioned attributes even exist in the context of Power Pages and if so how does one go about querying this information?

 

Thanks in advance!

 

Categories:
I have the same question (0)
  • oliver.rodrigues Profile Picture
    9,455 Most Valuable Professional on at

    Hi, you should be able to access any attribute from the Contact record by using the User object. This includes country/language/custom attributes etc

    Available Liquid objects - Power Apps | Microsoft Learn

    Available Liquid objects - Power Apps | Microsoft Learn

  • iwaldman Profile Picture
    159 on at

    Thanks for the confirmation. 

     

    Do you know how to get the current user's time zone? I've tried the following:

     

     var adx_timezone = `{{user.adx_timezone}}`;
     console.log(`adx_timezone = ${adx_timezone}`); 
     // adx_timezone = 20
    
     console.log(`browser timezone = ${Intl.DateTimeFormat().resolvedOptions().timeZone}`); 
     // browser timezone = America/Chicago

     

    Is there a way to convert "adx_timezone = 20" to its display name? 

  • Verified answer
    oliver.rodrigues Profile Picture
    9,455 Most Valuable Professional on at

    @iwaldman the timezone comes from a table in Dataverse. Below fetch would bring the results based on the user timezone:

    {% fetchxml timezoneDefinition %}
     <fetch mapping="logical">
     <entity name="timezonedefinition" >
     <attribute name="userinterfacename"></attribute>
     <attribute name="standardname"></attribute>
     <filter type='and'> 
     <condition attribute='timezonecode' operator='eq' value='{{ user.adx_timezone }}' /> 
     </filter> 
     </entity>
     </fetch>
     {% endfetchxml %}
     {% for timezone in timezoneDefinition.results.entities %} 
     <div>User Interface Name: {{timezone.userinterfacename}}</div>
     <div>Standard Name: {{timezone.standardname}}</div>
     {% endfor %} 

    Don't forget to add Table Permissions to the timezonedefinition table

    Not sure if this table is retrievable by WebAPI, it might be an option as well

  • iwaldman Profile Picture
    159 on at

    @OliverRodrigues Worked like a charm, thanks!

    webapi.safeAjax({
     type: 'GET',
     url: `/_api/timezonedefinitions?$select=standardname,timezonecode,userinterfacename&$filter=timezonecode eq ${'{{ user.adx_timezone }}'}`,
     contentType: 'application/json',
     success: function (data, textStatus, xhr) {
     var results = data;
     console.log(results);
     for (var i = 0; i < results.value.length; i++) {
     var result = results.value[i];
     // Columns
     var timezonedefinitionid = result['timezonedefinitionid']; // Guid
     var standardname = result['standardname']; // Text
     var timezonecode = result['timezonecode']; // Whole Number
     var userinterfacename = result['userinterfacename']; // Text
     console.log({timezonedefinitionid, standardname, timezonecode, userinterfacename});
     }
     },
     error: function (xhr, textStatus, errorThrown) {
     console.log(xhr);
     },
     });

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
rezarizvii Profile Picture

rezarizvii 64

#2
DP_Prabh Profile Picture

DP_Prabh 34

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 30 Most Valuable Professional

Last 30 days Overall leaderboard