cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1059
Views
0
Helpful
5
Replies

Finesse with simple java script

ravi.kumar1
Level 1
Level 1

am new to finesse java scripting, am trying to get one simple java script that i have created to work with my finesse layout but it seems like it is not working. it just tests the agent status and based on that it is supposed to display a text message. please correct if anyone can. am putting the xml and .js file below and attaching the java script

 

<?xml version="1.0" encoding="UTF-8"?>
<Module>

<ModulePrefs title="Ravi Test"
        description="Testing java script">
    <Require feature="settitle" />
    <Require feature="dynamic-height" />
    <Require feature="pubsub-2" />
    <Require feature="setprefs" />
    
</ModulePrefs>

<Content type="html">
<![CDATA[
    

    <!-- jQuery -->
    <script type="text/javascript" src="/desktop/assets/js/jquery.min.js"></script>
   
    <!-- Finesse Library -->
    <script type="text/javascript" src="/desktop/assets/js/finesse.js"></script>

    <!-- Gadget Business Logic -->
    <script type="text/javascript" src="/3rdpartygadget/files/javatest.js"></script>

<script type="text/javascript">

    // initialize the gadget by loading the GoogleMaps javascript from Google based on the API Key
    // (Be sure to obtain and replace the API Key in GoogleMapsScreenPop.js)
    // and then run the gadget init handler
    
    window.onload = loadScript;
    
 

    </script>

 
]]>
</Content>
</Module>

 

_______________________________________________________________________

 

var agstate=finesse.restservices.User.States();

function loadscript(){
 if (agstate="NOT_READY")
 {
 document.write("Please go to ready state to accept the calls");
 }
 else
 {
 document.write("no problem, enjoy");
 }
}

5 Replies 5

dekwan
Cisco Employee
Cisco Employee

Hi,

 

Since you are new to Finesse gadgets/javascript, I would suggest that you go through the LearningSampleGadget as well as using it as a base of your gadget you would like to build. The reason why your gadget is not working is because you are not actually getting the agent state of the logged in user. You will get a better understanding after going through the learning sample gadget.

 

Thanx,

Denise

I did try looking at the sample gadgets, but am not sure about how to use those classes. Can you give me an example of how to get a user state in a variable , that would do a lot good to me to take further from there.

The learning sample gadget has step by step instructions on how to get the user state in a variable. I would suggest following the documentation in that sample gadget. If you do not want to follow the instructions, you can take the _Final version of the files and it will already have the code to get the user state in a variable.

See this, where is it


var finesse = finesse || {};

finesse.gadget = finesse.gadget || {};

finesse.container = finesse.container || {};

clientLogs = finesse.cslogger.ClientLogger || {}; // for logging


// Gadget Config needed for instantiating ClientServices

/** @namespace */

finesse.gadget.Config = (function () {

var _prefs = new gadgets.Prefs();


/** @scope finesse.gadget.Config */

return {

authorization: _prefs.getString("authorization"),

country: _prefs.getString("country"),

language: _prefs.getString("language"),

locale: _prefs.getString("locale"),

host: _prefs.getString("host"),

hostPort: _prefs.getString("hostPort"),

extension: _prefs.getString("extension"),

mobileAgentMode: _prefs.getString("mobileAgentMode"),

mobileAgentDialNumber: _prefs.getString("mobileAgentDialNumber"),

xmppDomain: _prefs.getString("xmppDomain"),

pubsubDomain: _prefs.getString("pubsubDomain"),

restHost: _prefs.getString("restHost"),

scheme: _prefs.getString("scheme"),

localhostFQDN: _prefs.getString("localhostFQDN"),

localhostPort: _prefs.getString("localhostPort"),

teamId: _prefs.getString("teamId"),

teamName: _prefs.getString("teamName"),

clientDriftInMillis: _prefs.getInt("clientDriftInMillis"),

compatibilityMode: _prefs.getString("compatibilityMode")

};

}());


/**

* The following comment prevents JSLint errors concerning the logFinesse function being undefined.

* logFinesse is defined in Log.js, which should also be included by gadget the includes this file.

*/

/*global logFinesse */


/** @namespace */

finesse.modules = finesse.modules || {};

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

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

return {

/**

* Performs all initialization for this gadget

*/

init : function () {

gadgets.window.adjustHeight();

}

};

}(jQuery));

--
Sent from

That is the base file. You need to follow the instructions in the LearningSampleGadget.pdf. If you don't want to do that, take a look at the SampleGadget_Final.js file, which has the completed gadget.
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: