Saturday, July 11, 2009

Siebel Scripts

This Script will be used if you want to merge multiple Accounts ata a time.


function Service_PreInvokeMethod (read, Inputs, Outputs)
{
var BOobj = TheApplication().GetBusObject("Account");
var BCobj = BOobj.GetBusComp("Account");
var x = Clib.fopen("C:\\Input.txt","rt");
var line;
TheApplication().TraceOn("C:\\trace.log", "Allocation", "All");
try{
line=Clib.fgets(x);
if(x!= null)
{
while(line != null)
{
var cmdArray = line.split("|");
var l_sWinnerId = cmdArray[0];
var l_sLoserId = cmdArray[1];
//TheApplication().RaiseErrorText( l_sWinnerId + l_sLoserId);
BCobj.InvokeMethod("SetAdminMode","TRUE");
BCobj.SetViewMode(3);
BCobj.ClearToQuery();
var searchExpr = "[Id]='" + l_sWinnerId + "' OR [Id] = '" + l_sLoserId + "'";
BCobj.SetSearchExpr(searchExpr);
BCobj.ExecuteQuery (ForwardBackward);
var rec1 = BCobj.FirstRecord();
TheApplication().Trace("The value of rec1 before while...." + rec1);
while(rec1)
{
if ( BCobj.GetFieldValue("Id") == l_sWinnerId)
{
//TheApplication().RaiseErrorText( l_sWinnerId);
//var mergeResult =BCobj.InvokeMethod("MergeRecords", l_sWinnerId, l_sLoserId);
//TheApplication().RaiseErrorText( l_sLoserId);
TheApplication().Trace("Started Merging the accounts ...." + l_sWinnerId + " and " + l_sLoserId);
//TheApplication().Trace("Merge Ended with result ...." + mergeResult );
rec1 = null;
TheApplication().Trace("The value of rec1 in the if loop...." + rec1);
}
else
{
rec1 = BCobj.NextRecord();
TheApplication().Trace("The value of rec1 after nextrecord...." + rec1);
}

}
line=Clib.fgets(x);
}
}
}
catch(e)
{
TheApplication().Trace(e);
throw(e);
}
Clib.fclose(x);
// finally
// {
BCobj=null;
BOobj=null;
// }
TheApplication().TraceOff();
}

No comments:

Post a Comment