Importing Clients Into SuiteCRM Using XML

Facebooktwittergoogle_pluspinterestby feather

I want to create a road map on how to automatically import lead and client data into SuiteCRM and this will be the working article I use to record my progress, and reference later.

Currently, the plan is to create a sub domain that all lead data will first go to for scrubing and massaging, and from there it will go on to the SuiteCRM system for import.

In the sub domain, the mapping of fields will occur, along with changing caps of any given data point, and phone numbers formated correctly etc….

Because PHP has a built-in parser called SimpleXML Parser (fair enough name for an XML parser I believe), I will attempt to use that and see how it goes.

In order to read an XML string of data, the PHP simpleXML_load_string() function is used.

Using sample test data, we can see this in action:

$ClientXMLData = 

"<?xml version='1.0' encoding='UTF-8'?>

<ContactInfo>

<FirstName>Lori</FirstName>

<LastName>Robert</LastName>

<heading>New Client</heading>

<CompanyName>ABC Company</CompanyName>

</ContactInfo>";

The above XML is read using the following code:

$xml=simplexml_load_string($ClientXMLData) or die("Error: Cannot create object");

print_r($xml);

The print_r should give us something that looks like:

SimpleXMLElement Object ( [FirstName] => Lori[LastName] => Robert[heading] => New Client [CompanyName] => ABC Company )

The XML documents I want to import includes the following fields

<InsuranceRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<ZipCode>78759</ZipCode>

<ContactInfo>

<FirstName>Isaac</FirstName>

<LastName>Allen</LastName>

<Address>79108 Mopac Hwy</Address>

<ZipCode>78759</ZipCode>

<City>AUSTIN</City>

<County>TRAVIS</County>

<State>TX</State>

<PhoneDay>8047528122</PhoneDay>

<PhoneEve>8048598397</PhoneEve>

<PhoneCell>8047528122</PhoneCell>

<Email>IsaacAllen262329296@test.org</Email>

<Comment>None</Comment>

</ContactInfo>

<BusinessPropertyInsurance>

<CompanyName>Test Company</CompanyName>

<LegalEntity>Sole Proprietorship</LegalEntity>

<YearsInBusiness>40</YearsInBusiness>

<Revenue>Under $100,000</Revenue>

<Partners>29</Partners>

<FullTimeEmployees>6</FullTimeEmployees>

<PartTimeEmployees>14</PartTimeEmployees>

<SubContractors>9</SubContractors>

<SIC>0111</SIC>

<SeasonalBusiness>false</SeasonalBusiness>

<Subsidiaries>3</Subsidiaries>

<RequestedCoverage>

<General_Liability>false</General_Liability>

<Commercial_Auto>false</Commercial_Auto>

<Commercial_Property>false</Commercial_Property>

<Professional_Liability>false</Professional_Liability>

<Directors_and_Officers_Liability>false</Directors_and_Officers_Liability>

<Business_Owners_Package_Policy>true</Business_Owners_Package_Policy>

<Workers_Compensation>false</Workers_Compensation>

<Commercial_Crime>false</Commercial_Crime>

</RequestedCoverage>

</BusinessPropertyInsurance>

</InsuranceRequest>

Comments

comments

Call and receive expert consulting or click below for quote
Button linked to quote page for commercial insurance quote