Create a Siebel Business Service

Create a Siebel business service that tells Siebel CRM how to respond to specific events from Live Experience.

Using Siebel Tools, create a business service called LX Handler Service. The sample code below performs the following actions:
  • When a call is answered (case "CallStart"): uses the caller's email address as a lookup key to retrieve the caller's contact details in the Siebel CRM system and display them in the agent view.
  • When a call is ended (case "CallEnd"): creates a Siebel CRM activity report with all the call details such as call start and end times, session type, and description, and displays it in the agent view.
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
 var nReturn = ContinueOperation;
 TheApplication().TraceOn("trace.txt", "Allocation", "All");
 switch (MethodName) {
 case "CallStart":
 var targetView = "FIN Contact Service View";
 var emailAddress = Inputs.GetProperty("emailAddress");
 TheApplication().Trace(emailAddress);
 // establish business context
 var BO = TheApplication().GetBusObject("Contact");
 var BC = BO.GetBusComp("Contact");
 with (BC) {
 ClearToQuery();
 SetSearchSpec("Email Address", emailAddress);
 ExecuteQuery(ForwardBackward);
 }
 // drive to view
 TheApplication().GotoView(targetView, BO);
 nReturn = CancelOperation;
 break;
 case "CallEnd":
 var emailAddress = Inputs.GetProperty("emailAddress");
 var targetView = "Contact Detail View";
 var startTime = new Date(Number(Inputs.GetProperty("startTime"))*1000);
 var endTime = new Date(Number(Inputs.GetProperty("endTime"))*1000);
 var callLocation = Inputs.GetProperty("location");
 var appName = Inputs.GetProperty("appName");
 TheApplication().Trace(emailAddress);
 // establish business context
 var BO = TheApplication().GetBusObject("Contact");
 var BC = BO.GetBusComp("Contact");
 with (BC) {
 ClearToQuery();
 SetSearchSpec("Email Address", emailAddress);
 ExecuteQuery(ForwardBackward);
 }
 var BCAction = BO.GetBusComp("Action");
 with (BCAction) {
 NewRecord(NewBefore);
 SetFieldValue("Type", "LX Session");
 SetFieldValue("Description", "Call from " + callLocation + " using " + appName + " app");
 //Siebel Date Format: mm/dd/yyyy hh24:mi:ss
 SetFieldValue("Planned", (startTime.getMonth()+1) + "/" + startTime.getDate() + "/" + startTime.getFullYear() + " " + startTime.getHours() + ":" + startTime.getMinutes() + ":" + startTime.getSeconds());
 SetFieldValue("Planned Completion", (endTime.getMonth()+1) + "/" + endTime.getDate() + "/" + endTime.getFullYear() + " " + endTime.getHours() + ":" + endTime.getMinutes() + ":" + endTime.getSeconds());
 WriteRecord();
 }
 // drive to view
 TheApplication().GotoView(targetView, BO);
 nReturn = CancelOperation;
 break;
 }
 return (nReturn);
}