Usage Collection – Viewing data in Siebel

This is the follow up post to the earlier post I had written about vanilla Siebel functionality called Usage Collection which helps in collecting usage statistics about Siebel Application. This can come in really handy when you are trying to cleanup your Siebel Application and focus more on areas of importance.

The best way to analyze this data will be through OBIEE reports where you can slice and dice this data according to your needs, but there are lot of implementations out there that don’t use OBIEE. So, the second best thing that you can do is to display this data inside Siebel Applets so that users don’t have to go though CSV or XML files. This is where VBC comes into the picture.

You can easily build a view based on VBC that can read this data directly from file and display it in a Siebel Applet. It might not be best possible solution but it does the job.

So before we jump to our solution let’s get some basic information about a VBC.

  • A Virtual Business Component is business component based on class CSSBCVExtern.
  • A VBC does not have an underlying table.
  • It is primarily used to fetch data from external data source such as File, External DB, Web Service and display in Siebel
  • VBC is tied to a Business Service (either Vanilla such as XML Gateway Service or custom) which holds the business logic.

Now, lets start with the solution. I will be sharing configuration of VBC and the Business Service. The basic configuration steps such as creating a view and applet are out of scope for this article. For this example I am assuming that you enabled the Usage Tracking service and selected CSV and file format.

Creating a VBC:

  • Go to Business Component Object in Siebel Tools
  • Create a New Record and provide the following information
    • Name: Usage Tracking
    • Class: CSSBCVExtern
  • Create a Business Component User Property and provide following information
    • Name: Service Name
    • Value: Test Usage Tracking Service
  • Create Fields for this business component. For this example I have created 6 Fields
    • Username
    • IP Address
    • Session Id
    • View Name
    • Start Time
    • End Time

Creating a Business Service:

  • Go To Business Service Object in Siebel Tools
  • Create a New Record and provide following details
    • Name: Test Usage Tracking Service
    • Class: CSSService

Now your VBC and Business service are tried together. You just need to write the logic in the business service. You need to define atleast two methods in the Business Service based on VBC.

  1. Init : Used to initialize the fields of VBC. Only the fields initialized in Init method are available for use
  2. Query: This method actually defines the logic of initial view load.

The data in VBC is represented as a PropertySet. The VBC Fields are represented as properties and the rows/records are represented as child of PropertySet and finally here is the code for Init and Query method of business service

Init Method Code:

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
switch (MethodName)
{
case “Init” :
Outputs.SetProperty (“Username”, “”);
Outputs.SetProperty (“IP Address”, “”);
Outputs.SetProperty (“Session Id”, “”);
Outputs.SetProperty (“View Name”, “”);
Outputs.SetProperty (“Start Time”, “”);
Outputs.SetProperty (“End Time”, “”);
return (CancelOperation);
break;
case “Query” :
readFile(Inputs, Outputs);
return (CancelOperation);
break;
}
return (ContinueOperation);
}

readFile Method Code:

function readFile(Inputs, Outputs)
{
//  var filePath = Inputs.GetProperty(“FileName”);
var filePath = “C:\\SiebelUsageTracking2011-07-25_17.CSV”;
var oFile = Clib.fopen(filePath,”r”);
var str;
var usageAry = new Array();
var test:PropertySet = TheApplication().NewPropertySet();
try
{
if(oFile != null)
{
while(!Clib.feof(oFile))
{
str = Clib.fgets(4000,oFile);
usageAry = str.split(“,”);
test.SetProperty (“Username”, usageAry[0]);
test.SetProperty (“IP Address”, usageAry[1]);
test.SetProperty (“Session Id”, usageAry[2]);
test.SetProperty (“View Name”, usageAry[5]);
test.SetProperty (“Start Time”, usageAry[7]);
test.SetProperty (“End Time”, usageAry[8]);
test.SetProperty (“Status”, usageAry[9]);
Outputs.AddChild(test.Copy());
test.Reset();
}
}
}//end of try
catch(e)
{
//handle the error
}
finally
{
test = null;
usageAry = null;
}
}

If you have completed the configuration correctly this is what you will see in Siebel Application

image

This is the basic implementation of VBC and there are still lot of things that you can try on your own such as instead of hard coding the path and filename retrieve it from LOV, Implement searching and a lot of other things. I hope this will prove helpful to you. Let me know if you want SIF for BC and Business service objects I will share them.

Edit: The SIF file for VBC and Business Service are available here.

9 Responses to Usage Collection – Viewing data in Siebel

  1. Neel – Thanks for sharing…I’m newbie to Siebel so it would be great if you can share SIF for BC and Business service objects.

  2. Hi ,

    How to enable query and sort option in VBC. Lets say I am getting VBC data from business service which has already ‘Query’ and ‘Init’ method. Now I want to implement Applet level query (VBC applet) . Can anyone help me how to do this.

    below is my ‘Query’ method of business service

    function Query(Inputs,Outputs)
    {
    try
    {
    var temp = TheApplication().GetSharedGlobal(“sInContactToken”);
    if(temp == “” || temp == null)
    {
    var inp = TheApplication().NewPropertySet();
    var out = TheApplication().NewPropertySet();
    var GetAuthCode = TheApplication().GetService(“InContactGetTokenService”);
    GetAuthCode.InvokeMethod(“GetAuthToken”,inp,out);
    }

    if(TheApplication().GetSharedGlobal(“AppletQuery”) != “True”)
    {
    var baseURL = GetDescription(“IN_CONTACT”,”URL”,”Description”);
    var agentURL = GetDescription(“IN_CONTACT”,”AgentURL”,”Description”);
    var sID;
    sID = TheApplication().LoginName();
    var AgentId = GetDescription(“IN_CONTACT”,sID,”High”);
    agentURL = agentURL + AgentId;

    //Use EAI HTTP Transport to call Admin API
    var httpSvc= TheApplication().GetService(“EAI HTTP Transport”);
    var httpIn = TheApplication().NewPropertySet();
    var Out = TheApplication().NewPropertySet();
    httpIn.SetProperty(“HTTPRequestURLTemplate”, baseURL+agentURL);
    httpIn.SetProperty(“HTTPRequestMethod”,”GET”);
    httpIn.SetProperty(“HTTPIsSecureConn”,”TRUE”);
    httpIn.SetProperty(“HDR.Connection”, “keep-alive”);
    var token = TheApplication().GetSharedGlobal(“sInContactToken”);
    httpIn.SetProperty(“HDR.Authorization”,”bearer “+token);
    httpIn.SetProperty(“HTTPContentType”,”application/json;charset=UTF-8″);
    httpIn.SetProperty(“HDR.Accept-Encoding”,”identity”);
    httpIn.SetProperty(“HTTPAccept”,”application/json, text/javascript, */*; q=0.01″);
    httpIn.SetProperty(“HDR.User-Agent”,”something”);
    httpIn.SetProperty(“Accept-Language”,”en-US,en;q=0.8″);
    httpIn.SetProperty(“Accept-Charset”,”ISO-8859-1,utf-8;q=0.7,*;q=0.3″);
    httpSvc.InvokeMethod(“SendReceive”, httpIn, Out);

    //Transcode the JSON response into UTF-8
    var oTransOutputs = TheApplication().NewPropertySet();
    var oTransService = TheApplication().GetService(“Transcode Service”);
    Out.SetProperty(“ConversionMode”, “EncodingToString”);
    Out.SetProperty(“TargetEncoding”, “UTF-16”);
    Out.SetProperty(“SourceEncoding”, “UTF-8”);
    oTransService.InvokeMethod(“Convert”, Out, oTransOutputs);

    //Convert the JSON response to property set
    var oJSONConverter = TheApplication().GetService(“EAI JSON Converter”);
    oJSONConverter.InvokeMethod(“JSONToPropSet”,oTransOutputs,Out);

    var ChildOne=TheApplication().NewPropertySet();
    ChildOne=Out.GetChild(0);

    //Looping Child One
    var ChildTwoCount=ChildOne.GetChildCount();
    var iCountChildTwoMain=0;
    for (iCountChildTwoMain=0;iCountChildTwoMain<=(ChildTwoCount-1);iCountChildTwoMain++)
    {
    var ChildTwo=TheApplication().NewPropertySet();
    ChildTwo=ChildOne.GetChild(iCountChildTwoMain);

    var ChildCount=ChildTwo.GetChildCount();
    var iCount=0;

    for (iCount=0;iCount<=(ChildCount-1);iCount++)
    {
    var PropOut=TheApplication().NewPropertySet();
    PropOut=ChildTwo.GetChild(iCount).Copy();
    Outputs.AddChild(PropOut);
    }
    }
    TheApplication().SetSharedGlobal("AppletQuery","False")
    }
    else
    {
    var boAgent = TheApplication().ActiveBusObject();
    var bcAgent = boAgent.GetBusComp("InContact Agent Info VBC");

    bcAgent.ClearToQuery();
    bcAgent.ExecuteQuery(ForwardBackward);
    }
    return(ContinueOperation);
    }
    catch(e)
    {
    throw(e);
    }
    finally
    {
    httpIn = null;
    PropOut = null;
    ChildOne = null;
    ChildTwo = null;
    oTransOutputs = null;
    Out = null;
    inp = null;
    out = null;
    }
    }

    • Hi Jeevan, were you trying to integrate twitter? were you able to take it beyond authentication?

      to answer your question … you need to get sort-spec in Query method and change your property set accordingly.
      Something like Inputs.GetProperty(“sort-spec”); in Query Method. you would have figured it out by now.

      Can I ask what does SetSharedGlobal(“AppletQuery”,”False”) do?

      It will be great if we could talk more in detail in slack community. http://howtosiebel.blogspot.com/2015/11/lets-slack.html

      regards, Jim

Leave a Reply

Contribute