Get current logged in user in sharepoint 2013 hover display template

Hi,
Can somebody tell me how the current logged in username can be retreived in hover display template to be used in search result.
i tried using rest api but that is very difficult to get as it is to be done using ajax call and if we do getting a return value asynchronous is difficult.
Please help

Hello,
You might use the function used in the Visual Studio SharePoint App template:
var context = SP.ClientContext.get_current();
var user = context.get_web().get_currentUser();
$(document).ready(function () {
getUserName();
function getUserName() {
context.load(user);
context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
function onGetUserNameSuccess() {
$('#message').text('Hello ' + user.get_title());
function onGetUserNameFail(sender, args) {
alert('Failed to get user name. Error:' + args.get_message());

Similar Messages

  • Find Number of Users Currently Logged on to a SharePoint 2013 on premise server?

    Hello,
    We would like to know which current users are logged in our SharePoint farm.
    Is there a simple powershell script which we can run? or enable a feature
    Thanks,
    Dennis

    SharePoint is a web technology, which means it is connectionless by design.  So there really isn't such a thing as the number of users being logged on being tracked by the server.  The closest you can come is to have the server report how many
    active sessions haven't timed out yet.  Not quite the same thing since some of the sessions will be people who stopped using the system during the last half hour or so who's sessions haven't expired yet.  But its the closest you can come. Here's
    a deeper explanation and one potential solution.
    http://blog.furuknap.net/find-number-of-users-currently-logged-on-to-a-sharepoint-site
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • How to get spuserid of login user in sharepoint 2013

    i want to retrive the spuser id of login user in sharepoint 2013. using sp services

    Hello,
    Here is the code to get current user id:
    $().SPServices({
    operation: "GetUserInfo",
    async: false,
    userLoginName: $().SPServices.SPGetCurrentUser(),
    completefunc: function (xData, Status) {
    $(xData.responseXML).find("User").each(function() {
    curUserId = $(this).attr("ID");
    curUserName = $(this).attr("Name");
    http://yalla.itgroove.net/2011/12/sharepoint-2010-get-current-username-logged-in-user/
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to get current logged-in user name in data access driver or in universe

    In universe, to get the current log in user is via @Variable('BOUSER').
    Right now, I need to be able to get the user name in the data access driver. I am writing a customized data access driver because we need to patch some where clause on the the query generated by the universe based on the logged-in user info. I only think of using end_sql parameter or adding an universe level filter to patch the @Variable('BOUSER') to the query, which would not work if user want to use customized query.
    Can anyone tell me how to get currentBO user name from connection server ? or how @Variable('BOUSER') is translated into the logged-in user name in the universe?

    I do not know your EJB Service. But you should pass the credentials of the current logged on portal user to your service. That's not by default I think.
    I had a similar problem with CAF developed webservices. I had to turn on permission checks in my web service and passed the credentials via logon ticket.
    Regards, Bernd

  • OIM11gr2 - How to get currently logged in user details using oim api

    Hi All,
    I have a requirement to retrieve currently logged in users profile in the process adapter.
    I have tried with getSelfProfile in tcUserOperation and also ContextManager.getOIMUser API's however, in both the cases i am getting xelsysadm details only.
    Also as know request details in Process task mapping doesnot work for OIM11g onwards (its returning column not found exception )
    DOes any one has idea how to achieve this.
    PS. - i am using platform to retrieve API's.
    Thanks & Regards
    Swati Pandey

    You can get the logged in user name using the below java code:
    ADFContext adfCtx = ADFContext.getCurrent();
    SecurityContext secCntx = adfCtx.getSecurityContext();
    String user = secCntx.getUserPrincipal().getName();
    HTH

  • How to get Current Logged in user in Java

    Hi All ,
    I have written a code in to get the current logged in user in the portal in an EJB service.  I have used the code
    *IUser user= UMFactory.getAuthenticator().getLoggedInUser();*. But surprisingly the userId which it returns is always is Guest. Can you please help on this issue.
    Thanks & Regards,
    Rohit

    I do not know your EJB Service. But you should pass the credentials of the current logged on portal user to your service. That's not by default I think.
    I had a similar problem with CAF developed webservices. I had to turn on permission checks in my web service and passed the credentials via logon ticket.
    Regards, Bernd

  • How to get current logged in user's star rating in SharePoint 2013

    Hi,
    Currently,  I am developing a custom web part to show star rating for documents, everything is done.
    However,when user hover on the star I want a tooltip message("Your current rating is 1..."), similar to what we have 
    in libraries(or what the sharepoint by default provides in libraries) . So can I get the user specific rating depending upon 
    the logged in user using code(.net or CSOM anything will work)

    using the below code you can get the rated by user along with the rating , it's easier to just notify the user that her already rated the document 
    var acontext = new SP.ClientContext.get_current();
    var lists=acontext.get_web().get_lists();
    var l =lists.getByTitle("Documents"); //your document libraty
    var aitem=l.getItemById(27);//Item id
    acontext.load(aitem, "RatedBy", "ID", "Ratings");
    acontext.executeQueryAsync(function(){
    var RatedBy= aitem.get_item('RatedBy');
    if (!SP.ScriptHelpers.isNullOrUndefined(ratings)) {
    for (var i = 0; i < RatedBy.length; i++) {
    var user = RatedBy[i];
    if (user.get_lookupId() == _spPageContextInfo.userId) {
    //show that you already rate it
    break;
    },function(s,e){alert(e.get_message());});
    another way is to use CAML query to check if the current user id is within the RatedBy multi user field
    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

  • How to get currently logged in user on 'Bill of Material' Form in Add-Mode

    Dear All,
                    I am using a UDF on 'Bill of Material' Form in SAP. This UDF is named as Current_User. I want in this UDF the user name that is currently logged in to SAP. I am able to get user name at form load event. But when 'Bill of Material' Form comes in ADD Mode, the user name doesn't display. What can I do for this problem.? Here is my code:
    public override void Handle_SBO_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
                BubbleEvent = true;                 
                try
                    if ((mst_FormUIDModal != null))
                        if (FormUID != mst_FormUIDModal)
                            bool dbo_FormFound = false;
                            foreach (SAPbouiCOM.Form dsa_Form in this.SBO_Application.Forms)
                                if (dsa_Form.UniqueID == mst_FormUIDModal)
                                    if (FormUID != mst_FormUIDModal)
                                        if (this.SBO_Application.Forms.Item(mst_FormUIDModal).Selected == false)
                                            this.SBO_Application.Forms.Item(mst_FormUIDModal).Select();
                                        BubbleEvent = false;
                                        return;
                                    dbo_FormFound = true;
                            if (!dbo_FormFound)
                                this.mst_FormUIDModal = null;
                    if (pVal.BeforeAction == false)
                        switch (pVal.EventType)
                            case BoEventTypes.et_FORM_LOAD:
                                    if (pVal.FormType == -672)
                                        Program.Curr_User = SBO_Company.UserName;
                                        doc_form = this.SBO_Application.Forms.GetForm(pVal.FormType.ToString(), pVal.FormTypeCount);
                                        ((SAPbouiCOM.EditText)doc_form.Items.Item("U_User").Specific).Value = Program.Curr_User;
                                } break;

    Hi,
    You need not to write any sdk code for this task. You just create a user query as mentioned above and save it with some name.
    Then Open the Bill Of Material Screen, just click in the required field, then click alt + shift + f2 to assign a Formatted Serach.
    Then Select 3 rd Option       "Search in Existing User-Defined Values According to Saved Query"
    Then Click on the button "Open Saved Query"
    It will open the Query Manager. Select the Saved Query.
    Enable the Option "Auto Refresh When Field Changes"
    In the Drop Down list, select the Value "Parent Item"
    Then Select the Option Refresh Regularly or Display Saved Values.
    This will automatically put the user code if the parent item is selected.
    You an achieve this by without SDK Code.
    PS:
    There is a change in the Above Query:
    Select USER_CODE from ousr where userid = $[USER]
    Edited by: Manikandan K on Dec 22, 2011 2:00 PM

  • Command in JSP to get current logged in user.

    Hello Experts,
    We have a web page written in JSP.
    Once we call to this web page. I want to fetch username of the person who has logged in currently to system.
    is there is any single word command to get this ?
    Thanks In Advance..
    Avinash Shrivastava

    avinash101 wrote:
    Hi BalusC,
    First of all Thanks for your reply, but this JSP page will be saved in Server and user will access this site from client machine.
    Please suggest how to go in this scenario.
    Thanks Again,
    AvinashJSP runs at the server machine. It would only return the user name of the server machine. All what the client got is the HTML output produced by JSP, it doesn't get any line of JSP/Java code. You need to run Java at the client machine. A signed applet and web start app can do that.

  • Get current logged portal  user information

    Hi,
    I need to get information about current user logged to the portal from a J2EE application. I developed an Enterprise application project with a java servlet and I integrated it into the portal as an URL iView.
    This in the code of servlet:
    import com.sap.security.api.*;
    IUserFactory userFactory= UMFactory.getUserFactory();
         IUser user= UMFactory.getAuthenticator().getLoggedInUser();
         out.println(user.getUniqueID().toString());
         out.println(user.getDisplayName().toString());
         out.println(user.getName().toString());
         out.println(user.getUniqueName().toString());
    When I run my application I have this output:
    USER.PRIVATE_DATASOURCE.un:Guest Guest, Guest Guest
    But I access with another user, it's not Guest.
    How can I solve this problem???THANKS

    Hi,
    Please try checking with following code
    ISearchResult rst = UMFactory.getUserFactory().getUniqueIDs();
                      IUserFactory usf = UMFactory.getUserFactory();
                      IUser iuser = null;
                      IUserListElement userElement = null;
                      int i = 0;
                      while (rst.hasNext()) {
                      iuser =  UMFactory.getUserFactory().getUser(rst.next().toString());
                      String email = iuser.getEmail();
                       String fname = iuser.getFirstName();
                        String lname = iuser.getLastName();
    let me know if there are any issues.
    regards
    Anil

  • Get current logged in user's Apple ID

    Hi,
    I'm trying to implement a rating feature on an app I'm developing, but it's giving me a problem wich is that every user of the app can rate something one and only one time, wich means I can't use his/her IP nor MAC Address, I need something global like the user's e-mail associoated with apple's account, Apple ID or wathever it is that distinguishes users in the App Store. So, is there a way of getting this information in AIR or native language (so I can create an ANE)? Just a simple method that returns the user's ID is what I need.
    Thanks in advance.

    Ok, after some ersearch I found an extension by MilkmanGames called RateBox, here are some links:
    http://www.milkmangames.com/blog/tools/#ratebox (for the extension)
    http://www.adobe.com/devnet/air/articles/ratebox-ane-ios-android.html (for a tutorial)
    Can anyone confirm if this works for rating in-app purchases? I don't wanna buy this without knowing if it'll really work for what I want.

  • SharePoint 2013 Search Display Template People Search Mobile Phone

    Hello,
    I'd like to customize the people search result page. I already added some custom profile properties without any problem. But, when adding the MobilePhone field nothing is display.
    I've created a new display template based on the "Item_Person.html" file. 
    Added the "MobilePhone" field in the ManagedPropertyMapping section
    <mso:ManagedPropertyMapping msdt:dt="string">&#39;WorkPhone&#39;:&#39;WorkPhone&#39;,&#39;MobilePhone&#39;:&#39;MobilePhone&#39;,&#39;Room&#39;:&#39;Room&#39;,&#39;Werkgebieden&#39;:&#39;Werkgebieden&#39;,&#39;AboutMe&#39;:&#39;AboutMe&#39;,&#39;AccountName&#39;:&#39;AccountName&#39;,&#39;BaseOfficeLocation&#39;:&#39;BaseOfficeLocation&#39;,&#39;Department&#39;:&#39;Department&#39;,&#39;HitHighlightedProperties&#39;:&#39;HitHighlightedProperties&#39;,&#39;Interests&#39;:&#39;Interests&#39;,&#39;JobTitle&#39;:&#39;JobTitle&#39;,&#39;LastModifiedTime&#39;:&#39;LastModifiedTime&#39;,&#39;Memberships&#39;:&#39;Memberships&#39;,&#39;PastProjects&#39;:&#39;PastProjects&#39;,&#39;Path&#39;:&#39;Path&#39;,&#39;PictureURL&#39;:&#39;PictureURL&#39;,&#39;PreferredName&#39;:&#39;PreferredName&#39;,&#39;Responsibilities&#39;:&#39;Responsibilities&#39;,&#39;Schools&#39;:&#39;Schools&#39;,&#39;ServiceApplicationID&#39;:&#39;ServiceApplicationID&#39;,&#39;SipAddress&#39;:&#39;SipAddress&#39;,&#39;Skills&#39;:&#39;Skills&#39;,&#39;UserProfile_GUID&#39;:&#39;UserProfile_GUID&#39;,&#39;WorkEmail&#39;:&#39;WorkEmail&#39;,&#39;WorkId&#39;:&#39;WorkId&#39;,&#39;YomiDisplayName&#39;:&#39;YomiDisplayName&#39;</mso:ManagedPropertyMapping>
    3. Added a variable:
    var has_MobilePhone = !$isEmptyString(ctx.CurrentItem.MobilePhone)
    4. Copied the "WorkPhone" display section and changed the values to MobilePhone
    <!--#_
    if(has_MobilePhone == true) {
    _#-->
    <div id="MobilePhoneField">
    <!--#_
    var encodedMobilePhone = ctx.CurrentItem.MobilePhone;
    var displayMobilePhone = Srch.U.getSingleHHXMLNodeValue(hhProps, "MobilePhone");
    if ($isEmptyString(displayMobilePhone)) { displayMobilePhone = encodedMobilePhone }
    _#-->
    <div id="MobilePhoneValue" class="ms-srch-ellipsis" title="_#= encodedMobilePhone =#_">MobilePhone: _#= displayMobilePhone =#_ </div>
    </div>
    <!--#_
    _#-->
    Unfortunally the mobilephone does not appear in my search results. 
    What did I missed?

    First of all thank you for this quick reply.
    I changed all the properties from MobilePhone to CellPhone, but without result.
    <mso:ManagedPropertyMapping msdt:dt="string">&#39;WorkPhone&#39;:&#39;WorkPhone&#39;,&#39;CellPhone&#39;:&#39;CellPhone&#39;,&#39;Room&#39;:&#39;Room&#39;,&#39;Werkgebieden&#39;:&#39;Werkgebieden&#39;,&#39;AboutMe&#39;:&#39;AboutMe&#39;,&#39;AccountName&#39;:&#39;AccountName&#39;,&#39;BaseOfficeLocation&#39;:&#39;BaseOfficeLocation&#39;,&#39;Department&#39;:&#39;Department&#39;,&#39;HitHighlightedProperties&#39;:&#39;HitHighlightedProperties&#39;,&#39;Interests&#39;:&#39;Interests&#39;,&#39;JobTitle&#39;:&#39;JobTitle&#39;,&#39;LastModifiedTime&#39;:&#39;LastModifiedTime&#39;,&#39;Memberships&#39;:&#39;Memberships&#39;,&#39;PastProjects&#39;:&#39;PastProjects&#39;,&#39;Path&#39;:&#39;Path&#39;,&#39;PictureURL&#39;:&#39;PictureURL&#39;,&#39;PreferredName&#39;:&#39;PreferredName&#39;,&#39;Responsibilities&#39;:&#39;Responsibilities&#39;,&#39;Schools&#39;:&#39;Schools&#39;,&#39;ServiceApplicationID&#39;:&#39;ServiceApplicationID&#39;,&#39;SipAddress&#39;:&#39;SipAddress&#39;,&#39;Skills&#39;:&#39;Skills&#39;,&#39;UserProfile_GUID&#39;:&#39;UserProfile_GUID&#39;,&#39;WorkEmail&#39;:&#39;WorkEmail&#39;,&#39;WorkId&#39;:&#39;WorkId&#39;,&#39;YomiDisplayName&#39;:&#39;YomiDisplayName&#39;</mso:ManagedPropertyMapping>
    var has_CellPhone = !$isEmptyString(ctx.CurrentItem.CellPhone)
    <!--#_
    if(has_CellPhone == true) {
    _#-->
    <div id="CellPhoneField">
    <!--#_
    var encodedCellPhone = ctx.CurrentItem.CellPhone;
    var displayCellPhone = Srch.U.getSingleHHXMLNodeValue(hhProps, "CellPhone");
    if ($isEmptyString(displayCellPhone)) { displayCellPhone = encodedCellPhone }
    _#-->
    <div id="CellPhoneValue" class="ms-srch-ellipsis" title="_#= encodedCellPhone =#_">CellPhone: _#= displayCellPhone =#_ </div>
    </div>
    <!--#_
    _#-->
    Can you please tell me what I need to change?

  • Currently Logged in User

    Dear Experts
    i would like to know that how can we get the currently logged in user through query or some other option, as i want to generate different document series for every single user.
    Secondly, if i have a party which is my customer as well as my vendor, how i can perform netting so as to get the recievables and payables for the particular party.

    Hi,
    One way to get current logged in user list is through the XML file on the licensing server.  Otherwise, you can get current user by
    Select T0.U_Name From dbo.OUSR T0 Where T0.UserID = $[USER\].
    What is your B1 version and PL? It may not be the same for 2005 or 2007 to handle those BP with both types.
    Thanks,
    Gordon

  • Get username and password of the currently logged-in user in CRM and pass it to the plugin

    Hi,
    I am integrating CRM Online and SharePoint Online. Right now I am using Office365 trial version for both. Hence, the same username and password works for both.
    I want to create sub-site in SharePoint on create of an entity record. Currently, I am passing the admin credentials. But, I want to pass the credentials of the currently logged-in user in CRM to the plugin which is getting executed on create of account entity.
    So that I can then create sub-site in SharePoint using the current user credentials instead of admin credentials.
    Is there way to achieve this?

    Hello,
    You would not be able to get login/password of currently logged in user. I believe usage of admin credentials is the best way to achieve your goal.
    Dynamics CRM MVP
    My blog

  • How to get Current Log in BO user name in data access driver

    In universe, to get the current log in user is via @Variable('BOUSER').
    Right now, I need to be able to get the user name in the data access driver. I am writing a customized data access driver because we need to patch some where clause on the the query generated by the universe based on the logged-in user info. I only think of using end_sql parameter or adding an universe level filter to patch the @Variable('BOUSER') to the query, which would not work if user want to use customized query.
    Can anyone tell me how to get currentBO user name from connection server ? or how @Variable('BOUSER') is translated into the logged-in user name in the universe?

    Shweta,
    The link you provided was the Auditor guide for BO 6.x, I'm not sure it that is going to help Karen or not.
    Karen,
    There is function called connection
    (usage:  =connection([Query Name]), where [Query Name]
    denotes the name of the tab for the query under Edit Query)
    Here is some of the output from connection:
    4;ODBC18;MS SQL Server 2000166; VERSION=7; USER=xxxxx;
    PASSWORD=; DBTYPE=Relational; DATABASE=xxx_xxxx;
    ODBC_USER=xxxxxx; ODBC_PASSWORD=; BO_DSN=xxxx_xxxx;
    BO_DRV_CONNECT_MODE=0; 224; VERSION=6; Name=xxxxx; Shared=4;
    LoginTimeout=600; Timeout=600; Pool Time=60; Array Fetch Size=10;
    Array Bind Size=5; RecommendedLenTransfert=1000; Password_Encryption=x;
    AliasTable=; MeasureDimension=; Hint=; ConnectInit=; ArrayFetch=1;
    I'm not sure if this info helps out either, being that connection provides info on a post-processing basis and it sounds like you need to get out ahead of the SQL generation.  The @variable('bouser') would seem like the place to be, however, in allowing custom SQL to take place you loose the bouser due to an individual could customize the SQL to the point that it gets unwantingly yanked out.  The end_sql might be your answer...
    Thanks,
    John

Maybe you are looking for