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.

6 comments:

  1. Hi Rahul, Kindly can u share the code

    ReplyDelete
  2. There are numerous sorts of exercise manuals all through the a wide range of forms of Microsoft Excel. Excel Expert near me

    ReplyDelete
  3. First and foremost, on the off chance that you are attempting to plan spreadsheets for distribution, the table arrangement can turn out to be extremely restricting. excel consultants near me

    ReplyDelete
  4. Mike chose to compose books as he suspected he could contact a larger number of individuals this way rather than preparing individuals in classes. His first books turned out to be smash hits and his books have beaten blockbusters records from that point onward.placement cells database

    ReplyDelete
  5. "Flexibility is key when granting bereavement leave. Grieving individuals may need different amounts of time off depending on their relationship with the deceased, cultural practices, and the emotional impact." How to use bereavement leave at Walmart Cincinnati

    ReplyDelete

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...