cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2312
Views
0
Helpful
7
Replies

Displaying queues names and Call Volume in third-party Gadget.

juliancas
Level 1
Level 1

I need to display in a third-party gadget the queue name (for now) and I am following the sample-gadget documentation; in the handleUserLoad I get an instance of the queues collection for the user:


handleUserLoad = function (userevent) {

.

.

queues = user.getQueues({});

}

queues is a global variable in finesse.modules.SampleGadget = (function ($) { var user, queues...}(jQuery));

then in the render function I am adding:

render = function ( ) {

     var queueCollection = queues.getCollection();

     var queue;

     .

     .

     for (var queueId in queueCollection) {

         if (queueCollection.hasOwnProperty(queueId)) {

             queue = queueCollection[queueId];

     }

     $("\#queueName").text(queue.getName());

     .

     .

},...


The issue is that i can not get to display user's queue name, because it only has one. Note: I use "\" in the queueName but  in the program code that escape character is not there.


Thanks

7 Replies 7

dekwan
Cisco Employee
Cisco Employee

Hi Julian,

Unfortunately, it isn't that simple. A lot of the Finesse requests are asynchronous and therefore calling the method does not result in an immediate response. So, whenever you see "handlers" as the argument, it usually means that you have to have callbacks to handle the response when it comes. So, to get the queue, it goes something like this:

    // Here you will finally get the individual queue event/object where you can get the queue id, name, stats

    onQLoad = function(queue) {

        var qId = queue.getId();

        var qName = queue.getName();

        var qStats = queue.getStatistics();

    },

    onQChange = function(queue) {

    },

    handleQueuesChange = function (queues) { },

    handleNewQueues = function (queues) {

        queue.addHandler('change', handleQueuesChange);

    },

    handleQueuesDelete = function (queues) { },

    handleQueuesLoad = function (queuesEvent) {

        var queues = queuesEvent.getCollection();

        for(queueId in queues) {

            var queue = queues[queueId];

            queue.addHandler('change', onQChange);

            queue.addHandler('load', onQLoad);

        }

    },

    handleUserLoad = function (userevent) {

        // Get an instance of the dialogs collection and register handlers for dialog additions and

        // removals

        dialogs = user.getDialogs( {

            onCollectionAdd : handleNewDialog,

            onCollectionDelete : handleEndDialog

        });

        queues = user.getQueues( {

            onCollectionAdd : handleNewQueues,

            onCollectionDelete : handleQueuesDelete,

            onLoad: handleQueuesLoad

        });

    },

Make sure you add all of the change and load handlers at the appropriate places.

Thanx,

Denise

Hi Denise,

Thank you for helping me here, I did implement an onLoad : handleQueue handler when I instanced the queues object and use the callback handleQueue(queuesEvent) function to call display queues but it did not work, I did not do it like you just showed me though, I used something similar like dialog call handlers example. I will be working on your solution but I noticed that you used 2 more handlers add and change, are they really necessary? I assume that when a supervisor changes skill in agents they will have more or less queues to answer calls, and I do not mind use them here. My question is do we have to always add those handlers when instancing the objects like dialog or queues? for dialog I see that an user can have different media dialogs at one time but for queues I do not see that case quite often.

Thanks again.

Hi Julian.

Whoops. I just realized I was missing the part of the code that I call the getQueues. I updated my previous post.

I will be working on your solution but I noticed that you used 2 more handlers add and change, are they really necessary?

It really depends on what you are trying to accomplish with the queue information. If you need the realtime updates for the queue stats, then probably. I just put it in blindly without really thinking too much about it.

My question is do we have to always add those handlers when instancing the objects like dialog or queues?

For dialogs, you need the add handler so that you will know when you get a new call. You need to add the change handler for that new call so that you will get updated on any change (answer, hold, call variables, participants, etc) for that call. For queues, again, it depends on what you are using it for. If you just want the queue name, then maybe not?

Thanx,

Denise

Hi Denise,

I had the queues object instantiated before and your code correction confirmed it, I did it inside the handleUserLoad along with the dialog object, however, this call back function onLoad: handleQueuesLoad is not being called. The handlers for dialog works fine but for queues does not. Do you have any idea what would be the reason?

Thanks.

Hi Julian,

Check the syntax for your js file. Make sure everything matches and all handlers have the function created. Then use the browser's developer tools to breakpoint it and make sure that the getQueues code is being called. I tested the above code (of course they are a snippet of the whole file) and it works. I was able to hit the onQload function.

Thanx,

Denise

Denise,

Syntax seems ok and I used the breakpoint to check if the handler function was called which it was not, so I was wondering what would be the trigger to call handleQueuesLoad function?. I can see that dialog handlers are called when user makes a call, but in Queues I assume that just creating the user object will create the Queues collection object, am I correct?

Thanks.

Hi,

Does your user belong to a queue? You can find out by manually calling the Get List of Queues for the User REST API.

Look at the console of the browser's developer tools to see if there are any errors. Also make sure that the browser is loading the latest code by using nocache.

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: