By adminPublished: September 25, 2009Posted in: CRM Tips Technical, GeneralTags: 
//An example o opening a csv file and importing into Sage CRM
{
var fso, f1, ts, s;
var ForReading = 1;
fso = new ActiveXObject(“Scripting.FileSystemObject”);
f = fso.OpenTextFile(“c:\\John\\act.csv”, ForReading);
}
while (!f.AtEndOfStream)
{
var r = f.ReadLine();
var Idarr = r.split(“,”);
compid = Idarr[0];
compname = Idarr[2];
compstart = (Idarr[4]);
//Date is opened as string, so dissect it with a split and join as a date.
cd = compstart.split(“/”);
actdate = new Date();
actdate.setYear(cd[2]);
actdate.setMonth(cd[1]);
actdate.setDate(cd[0]);
eWare.AddContent(actdate);
ad = new String(actdate.getDate());
am = new String(actdate.getMonth());
//The months behave strangely when P12
if (am==0){
am = 12
}
if ((ad.length == 1)){
ad = “0″+ ad;
}
eWare.AddContent(‘<BR>’+ am + “/”+ ad +”/”+actdate.getYear() +’<BR>’);
comprec = eWare.FindRecord(“Company”,”Comp_CompanyId=”+compid);
recs = comprec.RecordCount;
if (recs > 0){
startdate = comprec.item(“comp_start”);
compname = comprec.item(‘Comp_name’);
dept = comprec.item(‘comp_dept’);
//Add Charter (our custom entity)
record = eWare.CreateRecord(“Charter”);
record.item(‘charter_signeddate’)= startdate;
record.item(‘Charter_companyid’) = compid;
record.SaveChanges()
chartid=record.item(‘Charter_charterId’);
var record6 = eWare.CreateRecord(‘charaction’);
record6.item(‘char_CompanyId’)=compid;
record6.item(‘char_chartid’)=chartid;
record6.item(‘char_startdate’)=startdate;
record6.item(‘char_tobeactioned’) = am + “/”+ ad +”/”+ay;
record6.item(‘char_name’)=compname
record6.item(‘char_completed’)=’No’;
record6.item(‘char_acttype’)=’CSQ’;
record6.item(‘char_department’) = dept;
record6.item(‘char_active’)=’No’
record6.item(‘char_order’)=6;
record6.SaveChanges();
chartactid = record6.item(‘char_charactionid’);
}
}
Response.Write(eWare.GetPage());
About the Author

John Waters (Director of Accounting Software Professionals) attained his IT and Accounting skills during the years when accounting systems were in their infancy. Spotting a niche in his chosen proefession as a Chartered Accountant, he has created a brand and breed of CA that bridges the gap between management needs and IT deliverables.