TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get the Current Logged User name in sharepoint 2013 using JSON
Sagar Pardeshi
Jun 20
2014
Code
17.6
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<script src=
"/Style Library/scripts/jquery-1.10.1.min.js"
></script>
<script type=
"text/javascript"
>
$(document).ready(
function
() {
var
currentUser;
// Ensure that the SP.js is loaded
if
(SP.ClientContext !=
null
) {
SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser,
'SP.js'
);
}
else
{
SP.SOD.executeFunc(
'sp.js'
,
null
, getCurrentUser);
}
function
getCurrentUser() {
context =
new
SP.ClientContext.get_current();
web = context.get_web();
currentUser = web.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(onSuccessMethod, onRequestFail);
}
function
onSuccessMethod(sender, args) {
var
account = currentUser.get_loginName();
var
title = currentUser.get_title();
currentUserAccount = account.substring(account.indexOf(
"|"
) + 1);
}
// This function runs if the executeQueryAsync call fails.
function
onRequestFail(sender, args) {
// alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
}
});
</script>
Get the Current Logged User name in sharepoint 2013