" /> Customization of GAD, database query with a pop up - Genesys CTI User Forum

Author Topic: Customization of GAD, database query with a pop up  (Read 5290 times)

Offline ralonso

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Customization of GAD, database query with a pop up
« on: July 19, 2011, 11:06:53 AM »
Advertisement
I'm doing tests customization of GAD.

When I get a new interaction event I want to open a popup and launch a query on a database (MSSQL) with the ANI of the call.

Following some examples I've seen in a Rene post , I managed to launch the popup when I get a call.

Before further testing I would like to know if I want to do is possible.

Sorry for my english.

Offline René

  • Administrator
  • Hero Member
  • *****
  • Posts: 1832
  • Karma: 62
Re: Customization of GAD, database query with a pop up
« Reply #1 on: July 21, 2011, 08:26:13 AM »
Hi,

Yes, it's definitely possible. However, you would need to deploy required ODBC drivers for MSSQL to GDesktop's Tomcat instance.

R.

Offline ralonso

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Customization of GAD, database query with a pop up
« Reply #2 on: August 16, 2011, 03:54:21 PM »
Hello again,

I am trying to extract the ANI of a call to generate the query in the database.
I'm using this code:

[quote]<%@ page language="java" buffer="none" contentType="text/html; charset=utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="com.genesyslab.ail.AilLoader" %>
<%@ page import="com.genesyslab.ail.AilFactory" %>
<%@ page import="com.genesyslab.ail.Interaction" %>
<%@ page import="com.genesyslab.ail.Interaction.Type" %>
<%@ page import="com.genesyslab.ail.InteractionVoice" %>
<%@ page import="com.genesyslab.ail.ws.interaction.voice" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript">
window.parent.includeGDFunctionalities(window);
function custom_load() {
activateGDFunctionalities();
}
function custom_unload() {
unactivateGDFunctionalities();
}
</script>
</head>
<body height="0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
onLoad="custom_load()" onUnload="custom_unload()">
<script language="javascript">
<%
String ani;
com.genesyslab.ail.ws.interaction.voice

AilFactory ail = AilLoader.getAilFactory();
String interactionId = request.getParameter("interactionId");
Interaction interaction = ail.getInteraction(interactionId);
if(interaction instanceof InteractionVoice)
{              InteractionVoice iv = (InteractionVoice)interaction;
ani = iv.getANI(); 
};
%>
ANI <b><%=ani %>
</script>
</body>
</html>[/quote]


the problem is do not return anything. ???

Offline ralonso

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Customization of GAD, database query with a pop up
« Reply #3 on: August 18, 2011, 08:17:47 AM »
hi,

anyone can help? I do not understand why do not return anything.

Regrads.

Offline René

  • Administrator
  • Hero Member
  • *****
  • Posts: 1832
  • Karma: 62
Re: Customization of GAD, database query with a pop up
« Reply #4 on: August 19, 2011, 06:56:42 AM »
Hi,

Please check that [i]interactionId[/i] parameter is passed to your JSP page.

[i]getInteraction[/i] method returns object of type Interaction so I'm not sure if your statement "[i]if(interaction instanceof InteractionVoice)[/i]" is correct.

R.

Offline ralonso

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Customization of GAD, database query with a pop up
« Reply #5 on: August 19, 2011, 07:03:49 AM »
this is my custom.xml

[code]<gcn-resources>
    <desktop>
    <javascript-onaddinteraction>
      <![CDATA[
                document.forms.welcomeForm.elements.interactionId.value = idInteraction;
                document.forms.welcomeForm.submit();
            ]]>
    </javascript-onaddinteraction>
    <html-body>
            <![CDATA[
                <form name="welcomeForm" target="_blank" method="get"
                      action="custom/welcome.jsp">
                    <input type="hidden" name="interactionId"/>
                </form>
            ]]>
        </html-body>
    </desktop>
</gcn-resources>[/code]

i get this http://gce/gdesktop/custom/welcome.jsp?interactionId=Phonecall-5001-006f01f47b204002
« Last Edit: August 19, 2011, 07:53:03 AM by ralonso »

Offline ralonso

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: Customization of GAD, database query with a pop up
« Reply #6 on: August 19, 2011, 12:06:25 PM »
I finally made ​​it work.
InteractionID not return the ANI field (do not know why) I picked up the information from the contactID.
I leave the code here in case anyone wants to use.
custom.xml
[code]
<gcn-resources>
    <desktop>
        <dictionary-class>custom</dictionary-class>
        <customer-records>
            <javascript-onload>
                <![CDATA[
                    switch(interactionType) {

                        case INTERACTION_VOICE:
                            selectTabByName("AdditionalInformation");
                            break;
                    }
                ]]>
            </javascript-onload>
            <tabs>
                <tab name="AdditionalInformation">
                    <dictionary-key>AdditionalInformation</dictionary-key>
                    <javascript-onselect>
                        <![CDATA[
                            document.forms.additionalInformationForm.target = getDetailFrameName();
                            document.forms.additionalInformationForm.elements.idInteraction.value = idInteraction;
                            document.forms.additionalInformationForm.elements.idContact.value = idContact;
                            document.forms.additionalInformationForm.submit();
                        ]]>
                    </javascript-onselect>
                    <html-body>
                        <![CDATA[
                            <form name="AdditionalInformationForm" action="custom\additionalInformation.jsp">
                                <input type="hidden" name="idInteraction">
                                <input type="hidden" name="idContact">
                            </form>
                        ]]>
                    </html-body>
                </tab>
            </tabs>
        </customer-records>
    </desktop>
</gcn-resources>

[/code]

additionalinformation.jsp
[code]
<%@ page language="java" buffer="none" contentType="text/html; charset=utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
<%
    com.genesyslab.ail.AilFactory factory = com.genesyslab.ail.AilLoader.getAilFactory();
    com.genesyslab.ail.Interaction interaction = factory.getInteraction( (String)request.getParameter( "idInteraction" ) );
    com.genesyslab.ail.ContactManager contactManager = factory.getContactManager();
    com.genesyslab.ail.Contact contact = factory.getContactManager().getContact( (String)request.getParameter( "idContact" ) ,null);
%>

<html>
<head>
<title>Informacion Cliente</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
    <body style="font-size: 13pt;" bgcolor="#ced3de">

</p>
       

<%
java.sql.Connection con;
java.sql.Statement s;
java.sql.ResultSet rs;
java.sql.PreparedStatement pst;


out.println("");
con=null;
s=null;
pst=null;
rs=null;


String url= "jdbc:jtds:sqlserver://localhost/pruebas";
String id= "prueba";
String pass = "Prueb11";
try{

Class.forName("net.sourceforge.jtds.jdbc.Driver");
con = java.sql.DriverManager.getConnection(url, id, pass);

}catch(ClassNotFoundException cnfex){
cnfex.printStackTrace();

}
String sql = "select * from contactos where telefono="+contact.getPrimaryPhoneNumber()+"";
try{
s = con.createStatement();
rs = s.executeQuery(sql);
%>

<%
while( rs.next() ){
%>
<tr>
<td>ID de Cliente: <%= rs.getString("cust_id") %></td>
<br></br>
<td>Numero de telefono: <%= rs.getString("telefono") %></td>
<br></br>
<td>Nombre del Cliente: <%= rs.getString("nombre") %></td>
</tr>
<%
}
%>

<%

}
catch(Exception e){e.printStackTrace();}
finally{
if(rs!=null) rs.close();
if(s!=null) s.close();
if(con!=null) con.close();
}

%>

</body>
</html>
[/code]