Sunday, 22 February 2015

Advanced Scripting with Custom Java Classes

Introduction:

The purpose of this article aims to let you understand the basic usage how UCCX script works with java classes by using an example.
UCCX version: 7.0.1
JDK version: 1.5.14
the script that will be used in this demo can be downloaded by this link:
 
https://drive.google.com/open?id=0B5tzzJsbkWkISXV0RDd4WF82Yjg&authuser=0

  1. Eclipse is recommended to edit any java programs, so let us start building a java class.
In this java class, we have a constructor that accepts “tel” variable which is a string used to store the calling number, getters and setters, ,“incCount()”is used to increase the counter by one when having gone through loop each time and ”toString()” is rewritten and returns “tel@count” string.

  1. Compiling and compressing
Create directory as “com/acme/info”, and then copy the “CustomerInfo.java” file to this directory. Open cmd, and type the following commands:

javac -source 1.5 -target 1.5 com\acme\info\CustomerInfo.java

jar fc CustomerInfo.jar com\acme\info\CustomerInfo.class

dir:

2015-02-20  20:49               974 CustomerInfo.jar

  1. Upload CustomerInfo.jar file to UCCX
Go “Applications”, “Document Management”
Locate to the folder path: default/classpath
System – Custom File  Configuration. Move jar file to the right panel
Restart
Restart

  1. Script Edit
Login CCX Editor as an authorized user
New File, choose a Queuing template called “Simple Queuing”
Click Variable Icon, and enter fully qualified class name in the type field and Name is Info:

Enter second String variable called tel
In order to retrieve the calling number, drag “get call contact info” icon right after the Accept
Set calling number variable to “tel”
Set variable to constructor
then
Click “…” button to set value to the variable:
Concentrate on Java tab, and then enter your java class name on constructor field. In the drop-down button, then choose it. In the parentheses, enter variable name “tel”. Click “Ok”
Expand the “Select Resource”, drag Do to make counter incremented when each loop caller is waiting for the Agent.
C:\Users\Administrator\Desktop\15LAB\Capture.JPG
In the expression editor, make variables hold objects
Use inCount() method
C:\Users\Administrator\Desktop\15LAB\Capture.JPG
Click Ok

Add an integer variable for saving how many times each loop has gone through
Open the expression editor
In the methods option, choose .getCount()

Test

2 comments:

  1. Thank you for your great sample. Can you please advice if we can upload .class files instead of .jar

    ReplyDelete
    Replies
    1. I am sure you can't because it asks to upload a jar file

      Delete