function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
var readfile = Clib.fopen("C:\\novacontact.txt","rt");
TheApplication().TraceOn("C:\\trace2.log", "Allocation", "All");
var BOobj = TheApplication().GetBusObject("Contact");
var BCobj = BOobj.GetBusComp("Contact");
var line;
if(readfile!= null)
{
while((line=Clib.fgets(readfile)) != null)
{
var cmdArray = line.split("|");
var IMS = cmdArray[0];
var Lname = cmdArray[1];
var Fname = cmdArray[2];
var Type1 = cmdArray[3];
var Sal = cmdArray[4];
var SubType = cmdArray[5];
var street = cmdArray[6];
var city = cmdArray[7];
var state = cmdArray[8];
var Pcode = cmdArray[9];
var Address = cmdArray[6];
var isRecord = 0;
TheApplication().Trace("Accounts from file ...." + Fname + " and " + Lname + "and '" + IMS + "'");
// TheApplication().RaiseErrorText(IMS);
if(IMS != "")
{
BCobj.ClearToQuery();
BCobj.SetSearchSpec("IMS Number",IMS);
BCobj.ExecuteQuery();
isRecord = BCobj.FirstRecord();
}
if(isRecord != true || isRecord == 0)
{
//TheApplication().RaiseErrorText(IMS);
BCobj.ActivateField("IMS Number");
BCobj.ActivateField("Last Name");
BCobj.ActivateField("First Name");
BCobj.ActivateField("Type");
BCobj.ActivateField("M/M");
BCobj.ActivateField("Sub Type");
BCobj.ActivateField("Street Address");
BCobj.ActivateField("City");
BCobj.ActivateField("State");
BCobj.ActivateField("Postal Code");
//Start writing
BCobj.NewRecord(NewBefore);
BCobj.SetFieldValue("IMS Number",IMS);
BCobj.SetFieldValue("Last Name",Lname);
BCobj.SetFieldValue("First Name",Fname);
BCobj.SetFieldValue("Type",Type1);
BCobj.SetFieldValue("M/M",Sal);
BCobj.SetFieldValue("Sub Type",SubType);
var MVGBC = BCobj.GetMVGBusComp("Street Address");
var oAssocBC = MVGBC.GetAssocBusComp();
oAssocBC.ClearToQuery();
var sSearchExpr = "[Street Address] = '" + street + "' and [City] = '" + city + "' and [State] = '" + state + "' and [Postal Code] = '" + Pcode + "'" ;
//var sSearchExpr = "[Postal Code] = '" + Pcode + "'" ;
TheApplication().Trace("SearchSpec Build ...." + sSearchExpr);
//TheApplication().RaiseErrorText(sSearchExpr);
oAssocBC.SetSearchExpr(sSearchExpr);
oAssocBC.ExecuteQuery (0);
//TheApplication().RaiseErrorText(sSearchExpr);
if (oAssocBC.FirstRecord())
{
//var a = oAssocBC.GetFieldValue("City");
//TheApplication().RaiseErrorText(oAssocBC.GetFieldValue("Street Address") + " " + oAssocBC.GetFieldValue("City") + " " + oAssocBC.GetFieldValue("State") + " " + oAssocBC.GetFieldValue("Postal Code"));
oAssocBC.Associate(NewAfter);
//TheApplication().RaiseErrorText("Done");
BCobj.WriteRecord();
}
oAssocBC = null;
//return (CancelOperation);
}
}
}
TheApplication().TraceOff();
BCobj = null;
BOobj = null;
}
No comments:
Post a Comment