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

Supervised Teams getUsers object

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
Cisco Employee

Re: Supervised Teams getUsers object

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

7 REPLIES 7
Cisco Employee

Re: Supervised Teams getUsers object

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

Beginner

Re: Supervised Teams getUsers object

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!

Beginner

Re: Supervised Teams getUsers object

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.

Cisco Employee

Re: Supervised Teams getUsers object

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

Highlighted
Beginner

Re: Supervised Teams getUsers object

That was it! ... thanks again Denise!

Beginner

Re: Supervised Teams getUsers object

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?

Cisco Employee

Re: Supervised Teams getUsers object

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

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards