1 Reply Latest reply on May 4, 2016 1:12 PM by carlesc RSS
    radhikari Newbie

    How can I show the list logged in users in a mashup?

    Is there a way to retrieve the data of currently logged in users and show that in a mashup? Please help.

      • Re: How can I show the list logged in users in a mashup?
        carlesc Ninja

        Hi Riya,

         

        This is the code I use ( where UserList it's a datashape with all the user fields, you can see it on AddRow sentence ):

         

        var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
          infoTableName : "InfoTable",
          dataShapeName : "UserList"
        });
        
        
        // -- Recover Active Users
        var activeUsers = Resources["CurrentSessionInfo"].GetActiveUsers({
          maxItems: 1000000 /* NUMBER */
        });
        
        
        // result: INFOTABLE dataShape: SearchResults
        var searchResult = Resources["SearchFunctions"].SearchPeople({
          maxItems: 1000000 /* NUMBER */,
          searchExpression: undefined /* STRING */,
            modelTags: undefined /* TAGS */,
          query: query /* QUERY */,
          aspects: undefined /* JSON */,
          excludedAspects: undefined /* JSON */,
            maxSearchItems: undefined /* NUMBER */
        });
        
        
        
        
        if (searchResult.rows.length) {
           var peopleNames = searchResult.rows[0].peopleResults;
           var nVpeopleNames = peopleNames.rows.length;
            var entry,user,logged,fullName;
            for (var i=0;i<nVpeopleNames;i++) {
                entry = peopleNames.rows[i];
                user = Users[entry.name];
                logged = activeUsers.Find({  name: entry.name });
                fullName = (((user.firstName==="")||(user.firstName==undefined))?entry.name:user.firstName+" "+user.lastName);
                result.AddRow({
                    userName: entry.name,
                    firstName: user.firstName,
                    lastName: user.lastName,
                    fullName: fullName,
                    logged: (logged?logged.isConnected:false),
                    title: user.title,
                    phone: (user.workPhone?user.workPhone:user.mobilePhone),
                    email: user.emailAddress
                });
             }
        }