computer, internet, programming, Microsoft Dynamics, Oracle, Java, J2EE, EJB, SAP, ecommerce strategies, hightech jobs, h1b, web design, MS SQL Server, reporting, customizations, software, ERP, MRP, accounting systems, CRM - popular articles
Microsoft CRM: Data Conversion – Import from Act!
• First you need to download Act! SDK from Best Software website
• Install Act! SDK on the computer, where you plan to do programming
• We’ll use asynchronous data export/import model, this means that we’ll design the system, containing two parts: export into XML and this XML file import into the CRM
• Lets code Act! data export application, we’ll use C# to address Act Framework classes, we’ll need these libraries:
using Act.Framework;
using Act.Framework.Activities;
using Act.Framework.Companies;
using Act.Framework.ComponentModel;
using Act.Framework.Contacts;
using Act.Framework.Database;
using Act.Framework.Groups;
using Act.Framework.Histories;
using Act.Framework.Lookups;
using Act.Framework.MutableEntities;
using Act.Framework.Notes;
using Act.Framework.Opportunities;
using Act.Framework.Users;
using Act.Shared.Collections;
• To connect to Act! database:
ActFramework framework = new ActFramework();
framework.LogOn("Act Username", "password", "SERVER”, "Database");
• Now we need Act field names to map them with the fields in the MS CRM:
private void ShowContactsFieldsDescriptions(ActFramework framework) {
ContactFieldDescriptor[] cFields = framework.Contacts.GetContactFieldDescriptors();
ContactFieldDescriptor cField;
for(int x = 0; x < cFields.Length; x++)
{
cField = cFields[x];
Console.WriteLine("Table Name: {0}", cField.TableName);
Console.WriteLine("Column Name: {0}", cField.ColumnName);
Console.WriteLine("Display Name: {0}", cField.DisplayName);
Console.WriteLine("ACT Field Type: {0}", cField.ACTFieldType);
Console.WriteLine("");
}
}
• Let’s get contact list and create the file for import instructions to MS CRM:
ContactList cList = framework.Contacts.GetContacts(null);
FileInfo t = new FileInfo("Contacts.xml");
StreamWriter stw = t.CreateText();
• Now we form export data:
for (int i = 0; i < cList.Count; i++) {
string strContactXml = "
ContactFieldDescriptor cField;
Object oValue;
// First Name
cField = framework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.FIRSTNAME");
oValue = cField.GetValue(cList);
if (oValue != null && !(oValue.ToString().Trim().Equals("")))
strContactXml += "
// Last Name
cField = framework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.LASTNAME");
oValue = cField.GetValue(cList);
if (oValue != null && !(oValue.ToString().Trim().Equals("")))
strContactXml += "
else
strContactXml += "
// Salutation
cField = framework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.SALUTATION");
oValue = cField.GetValue(cList);
if (oValue != null && !(oValue.ToString().Trim().Equals("")))
strContactXml += "
// Job Title
cField = framework.Contacts.GetContactFieldDescriptor("TBL_CONTACT.JOBTITLE");
oValue = cField.GetValue(cList);
if (oValue != null && !(oValue.ToString().Trim().Equals("")))
strContactXml += "
") + "]]
• This is only portion of the data, that could be transferred into CRM, the whole list of fields is too long for small article, but your could design the whole list of desired fields. Please, pay special attention to replace
HTML tag – this is required for text data transfer into CRM
• Next is import application creation. We will not describe here connection to MS CRM details – please read Microsoft CRM SDK if you need this examples. We’ll concentrate on the nature of the import.
The XML export file should look like this:
• Reading, parsing and MS CRM object creation look is relatively simple:
Microsoft.Crm.Platform.Proxy.BizUser bizUser = new Microsoft.Crm.Platform.Proxy.BizUser();
ICredentials credentials = new NetworkCredential(crmUsername, crmPassword, crmDomain);
bizUser.Url = crmDir + "BizUser.srf";
bizUser.Credentials = credentials;
Microsoft.Crm.Platform.Proxy.CUserAuth userAuth = bizUser.WhoAmI();
// CRMContact proxy object
Microsoft.Crm.Platform.Proxy.CRMContact contact = new Microsoft.Crm.Platform.Proxy.CRMContact ();
contact.Credentials = credentials;
contact.Url = crmDir + "CRMContact.srf";
CorrectXML("Contacts.xml", userAuth.UserId);
StreamReader reader = File.OpenText("Contacts.xml");
string input = null;
while ((input = reader.ReadLine()) != null)
{
string strContactId = contact.Create(userAuth, input);
Console.WriteLine("Contact {0} is created", strContactId);
log.Debug("Contact " + strContactId + " is created");
}
• Just consider in more details CorrectXML function – it places OwnerId into XML contact tree:
private void CorrectXML(string fileName, string userId) {
File.Move(fileName, fileName + ".old");
StreamReader reader = File.OpenText(fileName + ".old");
FileInfo t = new FileInfo(fileName);
StreamWriter writer = t.CreateText();
string input = null;
while ((input = reader.ReadLine()) != null)
{
input = Regex.Replace(input, "{_REPLACE_ME_}", userId);
writer.WriteLine(input);
}
reader.Close();
writer.Close();
File.Delete(fileName + ".old");
}
• Finally, we are launching export, import, opening MS CRM and looking at the contact list, transferred from Act!
• Separate task would be Sales data from Act!, Notes etc. – we plan to describe them in the future articles
Good luck with integration! If you want us to do the job - give us a call 1-630-961-5918 or 1-866-528-0577! help@albaspectrum.com
Andrew Karasev is Lead Software Developer in Alba Spectrum Technologies – USA nationwide Great Plains, Microsoft CRM customization company, serving clients in Chicago, Houston, Atlanta, Phoenix, New York, Los Angeles, San Francisco, San Diego, Miami, Denver, UK, Australia, Canada, Europe and having locations in multiple states and internationally ( http://www.albaspectrum.com )
Alba Spectrum popular articles series: FAQ, Reviews, Introductions, Product Selections, Advises, Definitions, online marketing
We are serving wholesale & retail customers in Illinois, California, Texas, Wisconsin, New York, Washington, Ohio, Michigan, Indiana, Arizona, New Mexico, Louisiana, Florida, Georgia, Minnesota, Utah, Virginia, Georgia, Hawaii, Iowa, Colorado, Ontario, Quebec, Alberta, British Colombia. We also serve customer internationally in New Zealand, Europe: UK, France, Poland, Italy, Germany, Russia, India, Byrma, Thailand, Holland, Denmark, Sweden, Norway, Indonesia, Austria, New Zealand, Pakistan, Afghanistan, Iran, Spain, Argentina, Brazil, Chile, Uruguay, Paraguay, Peru, Equador, Colombia, Venezuela, Panama, Costa Rica, Canada, South Africa, Nigeria, Portugal, Greece, Turkey, Asia: India, China, Philippines, South Korea, plus business metros: Chicago, Los Angeles, Phoenix, Boston, Atlanta, Minneapolis, Fargo, Seattle, Miami, Orlando, Detroit, Buffalo, Toronto, Paris, London, Montreal, Denver, Warsaw, Berlin, Prague, Rome, Karachi, Sao Paulo, Rio de Janeiro, Moscow, Buenos Aires, Dehli, Mumbai, Beigin, Cairo, San Francisco, Fremont, Naperville, Oakland, Melburn, Sidney, Sent Petersburg, Tampa, New Orleans, Houston, Dallas, Mexico City, Bogota, Caracas, Lima, Salvador, Recife, Brasilia, Curitiba, Goiania. http://www.albaspectrum.com