Tuesday, 12 December 2017

Load Employees in Siebel : Reading Data from Excel File using Clib Methods

Hello All,

In my previous posts about Loading Employees in Siebel i described the process through CSV file and IO based approach and Excel based approach. Now in this post lets try to load employees using Clib methods by reading a csv file.

In this post lets achieve the requirement using Clib methods like ,

Prerequisite,


Sample Code,


   var str;
   var usageAry = new Array();
   var filePath = "C:\\Employee.CSV";  //file path to place CSV file
   var oFile = Clib.fopen(filePath,"rt");  // Open file in read Mode
   var out;
   if(oFile != null)
   {
   while(!Clib.feof(oFile))                  //check for end of file
   {
   str = Clib.fgets(oFile);
   usageAry = str.split(",");               // Delimiter to separate data from the file
   var FirstName = usageAry[0];
   var LastName = usageAry[1];
   var PhoneNumber = usageAry[2];
   var Email = usageAry[3];
   var LoginName = usageAry[4];
   var Position = usageAry[5];
   var Responsibility = usageAry[6];
   }

Now we have values in variables which we can pass to siebel for inserting record, you can use below script.

//Initialize BC and Insert data
   var oBOEmp = TheApplication().GetBusObject("Employee"); 
   var oBCEmp = oBOLdVal.GetBusComp("Employee"); 
   with(oBCEmp) 
   { 
   ActivateField("Last Name"); ActivateField("First Name"); ActivateField("Email"); 
   ActivateField("Phone Number");  ActivateField("Login Name");   
   ClearToQuery();   
   InvokeMethod("SetAdminMode","TRUE"); 
   NewRecord(NewAfter);    
   SetFieldValue("Last Name",LastName); SetFieldValue("First Name",FirstName);       SetFieldValue("Email",Email); 
   SetFieldValue("Phone Number",PhoneNumber); SetFieldValue("Login Name",LoginName); 
   
   //Insert Responsibility Now 
   
var RespBC = GetMVGBusComp("Responsibility");
var AssocBC = RespBC.GetAssocBusComp();
//   TheApplication().RaiseErrorText(PrRecord + AssocBC);
  with(AssocBC)
  {
    SetViewMode(3);
ClearToQuery();
ActivateField("Name");
//search for the responsibility 
SetSearchSpec("Name", Responsibility);
ExecuteQuery(ForwardBackward);
var Respfound = FirstRecord();
if(Respfound) 
{
AssocBC.Associate(NewAfter);
  } 

//Insert Position Now
var PostnBC = GetMVGBusComp("Position");
var AssocPostnBC = PostnBC.GetAssocBusComp();
  with(AssocPostnBC)
  {
    SetViewMode(3);
ClearToQuery();
ActivateField("Name");
//search for the position 
SetSearchSpec("Name", Position);
ExecuteQuery(ForwardBackward);
var PosFound = FirstRecord();
if(Respfound) 
{
AssocBC.Associate(NewAfter);
  }
   WriteRecord(); //save record
   }

sample csv file looks like, 






your suggestions and comments are always welcome :-) ,for exact code you can mail me.

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...