Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Get the Current Logged User name in sharepoint 2013 using JSON
WhatsApp
Sagar Pardeshi
Jun 20
2014
17.8
k
0
1
<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
Up Next
Get the Current Logged User name in sharepoint 2013 using JSON