cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

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

radhikari
1-Visitor

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.

1 REPLY 1

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;

        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

        });

     }

}

Announcements


Top Tags