Get current logged in user name in SharePoint Online

To retrieve the current logged-in username in SharePoint Online, first edit the page and insert a script editor web part from the ribbon. Then add the below code:
<script type=”text/javascript”>
 function GetCurrentUserName()
{
alert(_spPageContextInfo.userLoginName);
}
</script>
<input type=’button’ value=’Submit’ onclick=”GetCurrentUserName();”/>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s