Server Script Examples
Define the following server scripts in the CTI_Test business service. These scripts are invoked by the event response and command described in Event Response Example and Command Example:
function Service_PreCanInvokeMethod (MethodName, &CanInvoke)
{
var ReturnVal = ContinueOperation;
switch (MethodName)
{
case "EvtBSGotoView":
case "CmdBSGotoView":
CanInvoke = "True";
ReturnVal = CancelOperation;
}
return (ReturnVal);
}
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
var ReturnVal = ContinueOperation;
switch (MethodName)
{
case "EvtBSGotoView":
EvtBSGotoView(Inputs, Outputs);
ReturnVal = CancelOperation;
break;
case "CmdBSGotoView":
CmdBSGotoView(Inputs, Outputs);
ReturnVal = CancelOperation;
break;
}
return (ReturnVal);
}
function EvtBSGotoView(Inputs, Outputs)
{
// Getting input arguments from Event Response parameters
var itemID = Inputs.GetProperty("myWorkItemID");
var ANI = Inputs.GetProperty("ANI");
// Invoking Business Service "Communications Session Manager" method
var ctibs = TheApplication().GetService("Communications Session Manager");
var ip = TheApplication().NewPropertySet();
var op = TheApplication().NewPropertySet();
ip.SetProperty("WorkItemID", itemID);
ctibs.InvokeMethod("GetWorkItemInfo", ip, op);
// Generate a screen pop to "Contact List View" with
// all the contacts whose last name start with letter "S"
var boGlobal = TheApplication().GetBusObject("Contact");
var bcContact = boGlobal.GetBusComp("Contact");
bcContact.SetViewMode(AllView);
bcContact.ClearToQuery();
bcContact.SetSearchSpec("Last Name", "S*");
bcContact.ExecuteQuery(ForwardBackward);
TheApplication().GotoView("Contact List View", boGlobal);
}
function CmdBSGotoView(Inputs, Outputs)
{
// Getting input arguments from Command Data parameters
var number = Inputs.GetProperty("PhoneNumber");
// Invoking Business Service "Communications Client" method
var ctibs = TheApplication().GetService("Communications Client");
var ip = TheApplication().NewPropertySet();
var op = TheApplication().NewPropertySet();
ip.SetProperty("PhoneNumber", number);
ip.SetProperty("ProfileName", "Siebel CTI");
ctibs.InvokeMethod("MakeCall", ip, op);
}