Get Logged In Users Count from SharePoint Site RRS feed

  • Question

  • Hi,

    I am currently working on office 365 SharePoint Site.

    The requirement is that "get Logged In User Count from SharePoint site and store it to dynamic table on daily basis".

    I have searched lots of blogs but not get appropriate solution.

    please help me with appropriate solution.


    Mithun Phapale.

    Sharepoint Developer

    Thursday, March 22, 2018 9:53 AM

All replies

  • Hi Mithun,

    i came a cross an article talking about getting and counting the number of the logged on users to sharepoint online and store the data to a list . you need to develop a script using SPServices for getting the current logged in user and store the value to SharePoint list. 

    Here's the article with screenshots 

     here's the steps list for implementing your need

    1- Create sharepoint list with Name is WhoIsOnline.

    2- Download jquery-1.4.2.js and jquery.SPServices-0.6.2.min.js

    3Go to Settings >> Site contents >> Open Style Library >> Create new folder is MyJS .Then upload jquery-1.4.2.js and jquery.SPServices-0.6.2.min.js to MyJS folder (remember check in and publish your JS)

    4-Now Open Sharepoint designer to connect to sharepoint 2013 online

    5-Open seattle.html or your custom master page to code SPServices

    6- Copy and paste this code before  <!--[if gte mso 9]><xml> and after <!--SPM:<SharePoint:CssRegistration Name="Themable/corev15.css" runat="server"/>-->

           <script type="text/javascript" src="../../Style Library/MyJS/jquery-1.4.2.js">//<![CDATA[//]]>
            <script type="text/javascript" src="../../Style Library/MyJS/jquery.SPServices-0.6.2.min.js">//<![CDATA[//]]>
            <script type="text/javascript">//<![CDATA[
            $(document).ready(function () {
                window.setInterval(function () {
                }, 5000);
            function GetListItems() {
                try {
                        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");
                                //curFullUserName = $(this).attr("ID") + ";#" + $(this).attr("Name");
                                    operation: "GetListItems",
                                    //webURL: "",
                                    async: false,
                                    listName: "WhoIsOnline",
                                    CAMLViewFields: "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Title' /><FieldRef Name='UserName' /><FieldRef Name='WhoIsOnline' /></ViewFields>",
                                    CAMLQuery: "<Query><Where><Eq><FieldRef Name='UserName' /><Value Type='User'>" + curUserName + "</Value></Eq></Where></Query>",
                                    completefunc: function (xData, Status) {
                                        //$(xData.responseXML).find("z\\:row").each(function () {=>return undefied
                                        $(xData.responseXML).find("[nodeName=z:row]").each(function () {
                                            //var id = $(this).attr("ows_ID");
                                            var currentTime = new Date();                                       
                                                operation: "UpdateListItems",
                                                listName: "WhoIsOnline",
                                                ID: $(this).attr("ows_ID"),
                                                valuepairs: [["Title", currentTime.toUTCString()]],
                                                debug: true,
                                                completefunc: null
                catch (e) { alert(e); }

    Best Regrads, Ahmed Madany MCTS @twitter http://twitter.com/ahmed_madany @Blog http://ahmedmadany.wordpress.com @LinkedIn http://eg.linkedin.com/pub/ahmed-madany/35/80/2b6

    Thursday, March 22, 2018 1:54 PM
  • Hi Ahmed Madany,


    The Blog is really helpful "http://mstechsharing.blogspot.in/2013/10/find-number-of-users-currently-logged.html", But i have to get "get Logged In User Count from SharePoint site and store it to dynamic table on daily basis". for managing User Licences.

    Please reply if you have another solution.

    Your help is highly appreciable.

    Thanks and Regards,

    Mithun Phapale

    Sharepoint Developer

    Friday, March 23, 2018 12:20 PM