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 Apps / Current User Name and ...
Power Apps
Answered

Current User Name and Email Id in Model Driven Application

(0) ShareShare
ReportReport
Posted on by 388

Hi,

 

How to retrieve current user name and email id in model driven app just like in canvas app(User().EmailId)? Any suggestion would be greatly appreciated.

 

 

Thank you,

 

I have the same question (0)
  • Drew Poggemann Profile Picture
    9,287 Most Valuable Professional on at

    Hi @aaedla ,

     

    Check out the following link to get the details you are looking for:

    https://carldesouza.com/dynamics-365-javascript-get-user/ 

    Another link that shows the email address (internal email)

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/126902/javascript---get-email-address-of-current-user/273544 

     

  • Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    Hello @aaedla 

     

    You can use below script

     

    For Getting Logged in User Name :

     

    var UserName = Xrm.Page.context.getUserName();

     

    For getting Logged in  User Email

     

    var loggedinUserId = Xrm.Utility.getGlobalContext().userSettings.userId.replace("{","").replace("}","");
    
    Xrm.WebApi.online.retrieveRecord("systemuser", loggedinUserId , "?$select=internalemailaddress").then(
     function success(result) {
     var internalemailaddress = result["internalemailaddress"];
     },
     function(error) {
     Xrm.Utility.alertDialog(error.message);
     }
    );

     

     

    Please mark as Answer if it is helpful and provide Kudos


    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
    Blog : https://microsoftcrmtechie.blogspot.com

  • Manoj Mane Profile Picture
    35 on at

    Hi @aaedla ,

    To get the Current logged-in User FullName :-
        --> var userSettings = Xrm.Utility.getGlobalContext().userSettings;
      --> var userFullName = userSettings.userName;

    To get the User email address we need to retrieve the User Record :- 

    var userSettings = Xrm.Utility.getGlobalContext().userSettings;
    var userGUID = userSettings.userId;

    Xrm.WebApi.retrieveRecord("systemuser", userGUID, "?$select=internalemailaddress,fullname").then(
    function success(result) {
    console.log("Retrieved values: Name: " + result.internalemailaddress + ", Revenue: " + result.fullname);
    // perform operations on record retrieval
    },
    function (error) {
    console.log(error.message);
    // handle error conditions
    }
    );

    Thanks,
    Manoj.
    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to help others find it.



  • OK29 Profile Picture
    388 on at

    Thank you for your comments Rampprakash. I created js file and then uploaded to component library but I can see only on Chnage event, there is no OnLoad event. I want to auto populate user email id when form loads.Can you please elaborate with step by step?

  • Verified answer
    Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    Hello @aaedla,

     

    1. Navigate to https://make.powerapps.com

    2. Click Dataverse --> Expand Tables --> Open Table where you want to input your script

    3. Click Forms --> Open Main Form --> Make Sure you are not clicking inside the WHITE BAR where the field is available, click Outside 

     

    SCREENSHOT FOR YOUR REFERENCE

     

    rampprakash_1-1641558194403.png

     

    Once you clicked at the Right side click events and input your onload Events 🙂

     

    Please mark as Answer if it is helpful and provide Kudos


    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
    Blog : https://microsoftcrmtechie.blogspot.com

     

     

  • OK29 Profile Picture
    388 on at

    Hi Rampprakash,

     

    OnLoad event is not showing up if I open table form from solution.

    One more question:  I am getting email id but how to auto populate email id in a field?

    Thank you.

  • OK29 Profile Picture
    388 on at

    I didn't find any way to auto populate current user email id in a model driven application field. I used power automate to update the field.

     

    Please let me know if there is any way to auto populate without using power automate flow.

  • BridgeInbetween Profile Picture
    56 on at

    @manojmane Is it Possible to add an If statement for the OnLoad event to only run if the field is blank? When opening a record, it will always change the field you configure the OnLoad event for, as the logged in user.

  • ryleybauer Profile Picture
    327 on at

    For those who don't want to use Javascript for this, I realized that the built-in Owner field always defaults to the current user, so I just set the default value to owner using a simple 1 step business rule. Even if owner changes, by choosing the "set default value" option, it shouldn't change when the owner does going forward.

     

    ryleybauer_0-1699569629330.png


    Please mark this response as helpful or the solution if you found this helped you 🙂 

  • ArturoDeLaRosa Profile Picture
    5 on at

    Great solution!, Thank you a lot!

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard