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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Unable to get User Ema...
Power Pages
Unanswered

Unable to get User Email id or User GUID (Azure AD Object ID) at PowerApps portal pages using Javascript

(0) ShareShare
ReportReport
Posted on by 10
 

Hi,
I am using PowerApps Azure AD login page to authenticate using AAD user Id.

But at the powerapps portal pages i am unabe to get the User email or User GUID (AZure AD Object Id) to send it as parameter in my javascript API call.   I also noticed when looked the browser developer toolbar that a script related to dynamics 365 is loaded in which it gets userName (which is AD GUID object) and the contactid  (note this is within the script and i can see only values not the script).
 
tried using Xrm.Utility.getGlobalContect()  but gets error Xrm is undefined. 
cannot use function User().Email because this a powerapps portal page not the canva =s formula
CDS user function can get only full name but not the email.
 
Appreciate your advise in getting the User email or User GUID.
 
Thanks.
Categories:
I have the same question (0)
  • Verified answer
    Satish1024 Profile Picture
    279 on at

    You can use Liquid objects to access the dynamic content of CRM entities. 

     

    For example, there is an object called "user". You can access full name of the user as {{user.fullname}} 

    So you can use the attribute logical name of the contact entity and access any attribute. If you want to access email id, {{user.emailaddress1}}. Similarly, Guid can be accessed {{user.contactid}}

     

    An example is given here: https://docs.microsoft.com/en-us/powerapps/maker/portals/liquid/liquid-objects

     

    Please mark it as answer if my post helps.

     

    Thanks
    Satish Reddy
    https://pascalcase.com

     

     

  • Pbv Profile Picture
    10 on at

    Excellent. Thankyou Satish.  

     

    May I know if you can help in understanding how would I be able to get this UserName Value which is a GUID (an object ID of Azure AD User) which is prepopulated under the portal script (as metnioned) when a user logged into the portal.

     

    I am curious to get this 'userName' value from the Dynamics 365 Portal attribute to avoid additional call at my function in getting the UserGUID when passed email Id as parameter in an objective to retrive the user group. 

     

    <script>

     window["Microsoft"] = window["Microsoft"] || {};
        window["Microsoft"].Dynamic365 = {
         Portal: {
          User: {
           contactId: 'xxxxxxxxxx',
           userName:  'xxxxxxxxx'
                        },
          version : '9.1.11.27',
          type: 'CDSStarterPortal',
          id: 'xxxxxxxxxxxxx'
         }

    </script>

    Thanks.

  • Satish1024 Profile Picture
    279 on at

    Liquid objects can be used in JS also.. 

    For example, 

    var name = '{{user.fullname}}';

    In your case, something like this:

     

     User: {
           contactId: '{{user.contactid}}'
    ......
    ......

     

  • AndKanPA Profile Picture
    214 on at

    Hello @Satish-Reddy ,

     

    but is it possible do use:

    {% fetchXML query %}
    ...
    {% endfetchxml %}

    too?

     

    Thanks,

    AndKan

  • Community Power Platform Member Profile Picture
    on at

     

    var name = '{{user.fullname}}';

    name resolves to undefined 

    anyone know why this might be?

    The var statement is inside a change event function

     

    Hello, {{ user.fullname | escape }}!

    puts Hello, Darin J! at the bottom of my form.

     

    alert("name:" + "{{user.fullname}}");

    displays:  name:{{user.fullname | encode }}

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard