0

I am using Client Side Rendering with JSLink in SharePoint 2013. How to get the email address of Logged in User using JS Link? I was trying to use Ctx.CurrentUser.Email which returns undefined.

1
  • You need to load the current user before using it Commented Oct 31, 2014 at 14:11

1 Answer 1

2

Try this

<script type="text/javascript">
    ExecuteOrDelayUntilScriptLoaded(init,'sp.js');
    var currentUser;
    function init(){
        this.clientContext = new SP.ClientContext.get_current();
        this.oWeb = clientContext.get_web();
        currentUser = this.oWeb.get_currentUser();
        this.clientContext.load(currentUser);
        this.clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded), Function.createDelegate(this,this.onQueryFailed));
    }

    function onQuerySucceeded() {
        //currentUser.get_email()
    }

    function onQueryFailed(sender, args) {
        alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
    }
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.