Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Javascript code to retrieve the username from logged in username

Posted on by 340

i want the javascript code to retrieve user full name from the logged in user name on the custom entitiy

*This post is locked for comments

  • Moshe Hayun Profile Picture
    Moshe Hayun 365 on at
    RE: Javascript code to retrieve the username from logged in username

    I guess that your function is called on OnLoad event.

    If yes, you should check in your function if the current value on field is different of the userName retrieved, and maybe add a setSubmitMode on your code.

    Can you please share your code?

  • Sandy Hello Profile Picture
    Sandy Hello 340 on at
    RE: Javascript code to retrieve the username from logged in username

    when i click on save button under record it is displaying unsaved changes when click once again on the button the record is saved

  • Moshe Hayun Profile Picture
    Moshe Hayun 365 on at
    RE: Javascript code to retrieve the username from logged in username

    What do you mean exactly by "the record is saved for two clicks"?

  • Sandy Hello Profile Picture
    Sandy Hello 340 on at
    RE: Javascript code to retrieve the username from logged in username

    Hi Mahadeo thanks for reply,it is working good but the record is saved for two clicks,what is the reason behind

    Note : Here i am populating the current username to custom text field.

  • Suggested answer
    Mahadeo Matre Profile Picture
    Mahadeo Matre 17,021 on at
    RE: Javascript code to retrieve the username from logged in username

    Hi,

    There is one method in Xrm.Page.context, which will give you logged in username

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

    for more details please check

    msdn.microsoft.com/.../gg334511.aspx

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Javascript code to retrieve the username from logged in username

    I think you should use Xrm.Page.context.getUserName(); from javascript

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans