cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1367
Views
1
Helpful
7
Replies

Supervised Teams getUsers object

gpworld
Level 1
Level 1

Being ever so the bumbling one, I am staggering my way through once again.  I am trying to retrieve the list of users for a supervisor gadget.  I have retrieved the array of  teams and know trying to pull the list of users for those teams.  Does anyone know the structure of the Users collection objection that is returned by the getUsers() call?  I cannot seem to get that to work.

1 Accepted Solution

Accepted Solutions

dekwan
Cisco Employee
Cisco Employee

Hi,

It seems like the documentation for this is completely wrong. I will open a doc bug for that. Here is how to use it...

_handleUserLoad = function (userevent) {

    var supervisedTeams = user.getSupervisedTeams()

    for (i = 0; i < supervisedTeams.length; i++) {

        var team = supervisedTeams[i];

        var teamObj = new finesse.restservices.Team({

            id: team.id,

            onLoad: _onTeamLoad

        });

    }

},

_onTeamLoad = function (team) {

    var users = team.getUsers({

        onLoad: _onTeamUsersLoad,

        onError: _onTeamError

    });

},

_onTeamUsersLoad = function(users) {

    var usersCollection = users.getCollection();

    for (var userId in usersCollection) {

        var user = usersCollection[userId];

        var userFirstName = user.getFirstName();

        var userLastName = user.getLastName();

    }

},

_onTeamError = function(users) { },

Basically, getSupervisedTeams() returns an Array of objects that contain the team id (but it isn't a finesse.restservices.Team object). You take the id of the team and create a finesse.restservices.Team object. When the object is loaded (onLoad), you call the team.getUsers method with the right handlers. In the onLoad handler for the getUsers, NOW you have the collection of finesse.restservices.User objects.


I tested this on a Finesse 11.5 system. I hope this helps!


Thanx,

Denise

View solution in original post

7 Replies 7

dekwan
Cisco Employee
Cisco Employee

Hi,

It seems like the documentation for this is completely wrong. I will open a doc bug for that. Here is how to use it...

_handleUserLoad = function (userevent) {

    var supervisedTeams = user.getSupervisedTeams()

    for (i = 0; i < supervisedTeams.length; i++) {

        var team = supervisedTeams[i];

        var teamObj = new finesse.restservices.Team({

            id: team.id,

            onLoad: _onTeamLoad

        });

    }

},

_onTeamLoad = function (team) {

    var users = team.getUsers({

        onLoad: _onTeamUsersLoad,

        onError: _onTeamError

    });

},

_onTeamUsersLoad = function(users) {

    var usersCollection = users.getCollection();

    for (var userId in usersCollection) {

        var user = usersCollection[userId];

        var userFirstName = user.getFirstName();

        var userLastName = user.getLastName();

    }

},

_onTeamError = function(users) { },

Basically, getSupervisedTeams() returns an Array of objects that contain the team id (but it isn't a finesse.restservices.Team object). You take the id of the team and create a finesse.restservices.Team object. When the object is loaded (onLoad), you call the team.getUsers method with the right handlers. In the onLoad handler for the getUsers, NOW you have the collection of finesse.restservices.User objects.


I tested this on a Finesse 11.5 system. I hope this helps!


Thanx,

Denise

Thanks Denise! That was right on the money and explained exactly what I needed as well. Thank you for the help and response!!  You rock as always!

Hi Denise, one follow up question.  I can see the update occurring when I inspect the supervisors browser showing the state change of the agent (ready/not ready), but it is not following the "onChange" handler that I have at all.

Hi,

Hm. Looking at some code for the Finesse Agent desktop, I see the following:

for (userId in usersCollection) {

      usersCollection[userId].addHandler('change', _onTeamUserChange);

}

Note that I haven't tested this out, but I think this is what you are looking for.

Thanx,

Denise

That was it! ... thanks again Denise!

Sorry for all the questions.  Hoping this is the last one.  Once I have access to _onTeamUserChange which is being invoked, I believe I pass in the 'userevent' variable do I not and does this not contain the actual update itself?  _onTeamUserChange(userevent) ... if this is the case, how can I parse the data for desired actions?  I can't seem to determine its structure.  I have found the following:

Sample Notification Payload

{ event: "PUT" source: "/finesse/api/User/1000" data: {} }  

To receive notifications for User object updates, a client within the Finesse Desktop must subscribe to finesse.api.user.1000.

{ content: "<Update> <data>[User Object]</data> <event>PUT</event> <source>/finesse/api/User/{id}</source> </Update>" object: { Update: { data: [User Object], event: "PUT", source: "/finesse/api/User/{id}" } } } 

but I cannot seem to make it work.  Point me in the right direction?

Hi,

You are correct about the userevent. The userevent should be the same structure as the User object: JsDoc Reference - finesse.restservices.User

I haven't tried this out myself though.

The best bet would be to use the browser's developer tool and breakpoint it in that function. You can see the structure of the userevent variable that way.

Thanx,

Denise

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: