In sharepoint online I am searchuing users from peaople directory there i want to show status of searched users like online, away, offline, busy, etc. so which is the best approach to achive this?

My result look alike as below image

enter image description here

That rectangular left vertical line is supposed to show in various colors as green for available/online..... Etc

  • Just want to confirm that if you want to add rectangular left vertical line , or the left vertical line are already exist but didn't show the status of users ? Jan 25, 2018 at 9:50
  • already exist but didn't show the status of users
    – Madhav
    Jan 25, 2018 at 10:55

2 Answers 2


Add following div tag where presence icon need to be displayed: enter image description here then insert the following code near the bottom of your template. This code registers a callback to load the script and display the presence icon for you.

AddPostRenderCallback(ctx, function(){
EnsureScriptFunc("clienttemplates.js", "RenderUserFieldWorker", function() {
    var getUserPersona = function() {
        var renderCtx = new ContextInfo();
        renderCtx.Templates = {};
        renderCtx.Templates["Fields"] = {};
        var fieldSchemaData = { "DefaultRender":"1", "PictureSize": "None"};
        var listSchema = {"EffectivePresenceEnabled": "1", "PresenceAlt": Srch.Res.item_People_NoPresenceAvailable};
        var userData = {"title": uName, "email": uEmail, "picture": uPicUrl, "sip": uSip};
        var personaControlElement = document.getElementById(userPersonaId);
        if (!Srch.U.n(personaControlElement))
            personaControlElement.innerHTML = RenderUserFieldWorker(renderCtx, fieldSchemaData, userData, listSchema);
        if(typeof(ctx.EnqueueImnRequest) == "undefined") { ctx.EnqueueImnRequest = false; }
        if (ctx.EnqueueImnRequest == false) {
            ctx.ClientControl.add_oneTimeResultRendered(function(){ if (typeof(ProcessImn) != "undefined") { ProcessImn(); } });
            ctx.EnqueueImnRequest = true;
  • the same code i have and that is not giving me any status of user.
    – Madhav
    Jan 24, 2018 at 8:03
  • Is it displaying offline or no status at all?The Presence only becomes available when you have Lync setup correctly. For Office 365 use the Desktop Setup to accomplish this. portal.microsoftonline.com/OLS/mysoftware.aspx?source=ehome
    – Deepmala
    Jan 24, 2018 at 8:45
  • I havent setuped lync
    – Madhav
    Jan 24, 2018 at 9:37

Are your users using Lync or Skype for Business? This code has two requirements.

  1. You are tracking presence with Lync (on-prem) or Skype for Business (Online) and the users are logged in.
  2. On the code page itself each Persona container must have a unique ID on the page. In the above code that is the userPersonaID value. If you have 5 people on the page there need to be 5 unique ID values.

You can review additional details about the control here: http://www.ableblue.com/blog/archive/2013/06/05/add-presence-to-sharepoint-search-results/

Your Answer

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

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