Created
April 23, 2015 10:43
-
-
Save ryanjonhealy/44a93ac73932a46252fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CustomExecuteFunction() { | |
var self = this; | |
self.context = new SP.ClientContext.get_current(); | |
self.web = context.get_web(); | |
self.currentUser = web.get_currentUser(); | |
context.load(self.currentUser); | |
self.asyncSuccess = function(sender, args) { | |
var user = this.currentUser; | |
console.log('asyncSuccess', user); | |
loc = window.location.href; | |
check = loc.indexOf('CurrentUser'); | |
if(check <0) | |
{ | |
// if not the redirect with appended query string | |
window.location= loc + "?CurrentUser=" + user.get_title(); | |
} | |
}; | |
self.asyncFailure = function(sender, args) { | |
alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace()); | |
}; | |
// actually fires off the AJAX request | |
// more info: http://msdn.microsoft.com/en-us/library/dn168907.aspx | |
context.executeQueryAsync( | |
Function.createDelegate(self,self.asyncSuccess), | |
Function.createDelegate(self,self.asyncSuccess) | |
); | |
} | |
ExecuteOrDelayUntilScriptLoaded(CustomExecuteFunction,'sp.js'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment