Current User Display Name

rss

Posted by Stu - Aug 10 ’16 at 08:37

How do you get the current users Display name?

Thanks

Stuart

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 1 month 6 days
    #1 by Dmitry Kozlov Aug 11 ’16 at 04:54

    Hi Stu,

    Please, use the code:

    SP.SOD.executeOrDelayUntilScriptLoaded((function () { 
        var ctx = new SP.ClientContext.get_current(); 
        var web = ctx.get_web(); 
        ctx.load(web); 
        var user = web.get_currentUser(); 
        user.retrieve(); 
        ctx.executeQueryAsync( 
        function () { 
          alert(user.get_title());
        }); 
    }), "SP.js"); 
    
  • Stu
    Member
    Member for: 5 years 5 months 20 days
    #2 by Stu Aug 11 ’16 at 05:49

    Thanks it worked perfectly

  • GregFitz
    Member
    Member for: 6 years 5 months 24 days
    #3 by GregFitz Oct 3 ’18 at 09:16

    [#1]:

    Hello,

     

    Hope all is well, I have a quick question hoping you can help with.

     

    I wanted to hide a table (or show) based on current user.

     

    Using the following script (thank you Dmitry for forum post) I can get the current user:

     

    SP.SOD.executeOrDelayUntilScriptLoaded((function () {

    var ctx = new SP.ClientContext.get_current();

    var web = ctx.get_web();

    ctx.load(web);

    var user = web.get_currentUser();

    user.retrieve();

    ctx.executeQueryAsync(

    function () {

    alert(user.get_title());

    });

    }), "SP.js");

     

     

    However trying to filter using the above var ‘user’ isn’t working .

     

     

    i.e.

     

    if (user == 'Reviewing%20%Manager') {

    $('.MgmtC').show(); // Enable

    } else {

    $('.MgmtC').hide(); // Disable

    }

     

    I must be missing something

     

    Thanks,
    Greg

     

  • annajenner
    Member
    Member for: 1 year
    #4 by annajenner Oct 27 ’20 at 08:10

    Hello ! Do you know a company that provides expert-level ios development services ? I am an entrepreneur and now I am planning to develop an online store in order people to make orders 24/7.
    Thanks in advance!

  • Karli Rath
    Member
    Member for: 11 months 10 days
    #5 by Karli Rath Nov 20 ’20 at 02:56

    You know that import and export business is the biggest business in the world and more that three billion folks are connected with. I have just got college paper writing services and read this wonderful post about import and export business which provided me many businees tips and info.

  • Berenice5
    Member
    Member for: 11 months 8 days
    #6 by Berenice5 Nov 20 ’20 at 03:12

    Are you searching for academic writing help and having a problem with writing BTEC assignments? BTEC coursework is the best solution to resolve your issues related to assignments. We are the qualified assistant to deal with your high-level assignments by pouring in our efforts to let you present the best of the write my assignment writing.

  • Berenice5
    Member
    Member for: 11 months 8 days
    #7 by Berenice5 Nov 20 ’20 at 03:13

    Are you searching for academic writing help and having a problem with writing BTEC assignments? BTEC coursework is the best solution to resolve your issues related to assignments. We are the qualified assistant to deal with your high-level assignments by pouring in our efforts to let you present the best of the write my assignment writing.

  • Oddyann
    Member
    Member for: 10 months 13 days
    #8 by Oddyann Dec 14 ’20 at 02:14

    <a href="https://www.reddit.com">Thanks!</a>

  • shub8923
    Member
    Member for: 9 months 24 days
    #9 by shub8923 Jan 4 ’21 at 05:46

    UPSEE Exam is conducted for students who have recently completed their

    schooling and want to take admission in any professional course. After qualifying

    for the examination, the student will go through counselling to choose the

    colleges of their choice. Moreover, students can visit our website to know the exam dated and syllabus for this exam.

     

Displaying 1 to 9 of 9 messages