AnsweredAssumed Answered

finesse User onLoad event

Question asked by chapelain36 on Feb 26, 2016
Latest reply on Feb 29, 2016 by dekwan

Hi, all.

 

I am learning to work with finesse gadgets using Learning gadget 10.5.1.
I declared an User object as in instruction.

 

finesse.modules.SampleGadget = (function($) {

    var user,

    handleUserLoad = function(userevent) {

        alert("user load");

        render();

    },

    handleUserChange = function(userevent) {

        alert("user change");

        render();

    },

    render = function() {

        var currentState = user.getState();

        // Examples of getting data from the User object (GET)

        $("#userId").text(user.getId());

        $("#firstName").text(user.getFirstName());

        $("#lastName").text(user.getLastName());

        if (user.hasSupervisorRole()) {

            $("#userRole").text('Supervisor');

        } else {

            $("#userRole").text('Agent')

        }

        $("#extension").text(user.getExtension());

        $("#userState").text(currentState);

        // Example of setting the user state (PUT)

        if (currentState === states.NOT_READY) {

            $("#goReady").show();

            $("#goNotReady").hide();

        } else if (currentState === states.READY) {

            $("#goNotReady").show();

            $("#goReady").hide();

        } else {

            $("#goNotReady").hide();

            $("#goReady").hide();

        }

        gadgets.window.adjustHeight();

    };

    /** @scope finesse.modules.SampleGadget */

    return {

        /**

        * Performs all initialization for this gadget

        */

        init: function() {

            alert("init");

            var prefs = new gadgets.Prefs(),

            id = prefs.getString("id");

            finesse.clientservices.ClientServices.init(finesse.gadget.Config);

            user = new finesse.restservices.User({

                id: id,

                onLoad: handleUserLoad,

                onChange: handleUserChange

            });

            states = finesse.restservices.User.States;

            gadgets.window.adjustHeight();

        }

    };

} (jQuery));

 

But there is no onLoad event, when I am logging into finesse desktop as agent.
It alerts only when I am starting to change manually the agent state onLoad event, then onChange event - and this is behaviour of final gadget version too.
If I am trying to acess user object properties in browser debugger - there is an error

 

Can u please explain me, what am I doing wrong? Or maybe I have the wrong understanding of event model?

 

With regards, Yuriy.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

But I can access User data only when I changing the agent state manually.

Outcomes