Changes

Jump to navigation Jump to search
26,716 bytes added ,  20:33, 4 June 2008
no edit summary
== Goal ==
Import records into SugarCRM without using existing functionality, but rather by writing some PHP tool to do the work. Records should go into Accounts and Contacts, which obviously implies a relationship.
 
== Resources Used ==
* http://www.sugarcrm.com/wiki/index.php?title=SOAP_Intro_and_Practical_Examples
== Ideas on How to do the import ==
My self-imposed goal requirement was to capture all of the data provided -- assuming the owner of the data collected it for a reason and that they wouldn't be too happy with a loss of data in a migration to a new application. I looked briefly at the import functionality exposed by the application, but noticed how the lead capture did not reflect the same data profile as the source that I had. 
=== Existing Work ===
My first instinct was to find info about somebody doing this before (e.g. APIs, Documentation, forum questions, Wikis)
My second instinct was to look at the source. Answers are always found in the source, with the caveat that it can be confusing and/or time-consuming to find those answers.
Looking at the full application import routines and the four-step forms for importing leads, it was obvious that there was a lot of machinery that I didn't necessarily need or want to get involved with to simply import records. For instance, I would not want to (re-)write the form and UI handling when I simply needed to insert records into a database. This made me reconsider using the SOAP example to do the job. In essence, it would only need to read the exercise data and create full records for the 50 provided leads.
<!--From looking at the source code of the import routines, I noticed that the modules/Import/config.php file defined various types of data formatsprofiles, and that the "Salesforce" one matched profile was close to the needs data that I had for mapping source data to our application contacts.
<source lang="php">
)
</source>
-->
 
Note: Soap examples seem to have changed with the addition of a version number, so you must be careful about what example you use, and generally rely on the source to be the definitive source ;-)
 
Getting on with the soap service, it is easy to discover the service profile and import the data
 
From the [http://freephile.com/crm/soap.php|soap.php] page (which shows the WSDL), we can get a definition of the available SOAP calls. For example, here is the definition of the 'create_account' method
 
<pre>
Name: create_account
Binding: sugarsoapBinding
Endpoint: http://freephile.com/crm/soap.php
SoapAction: http://freephile.com/crm/soap.php/create_account
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: create_accountRequest
parts:
user_name: xsd:string
password: xsd:string
name: xsd:string
phone: xsd:string
website: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: create_accountResponse
parts:
return: xsd:string
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http
Documentation:
Soap examples seem Name: create_contactBinding: sugarsoapBindingEndpoint: http://freephile.com/crm/soap.phpSoapAction: http://freephile.com/crm/soap.php/create_contactStyle: rpcInput: use: encoded namespace: http://www.sugarcrm.com/sugarcrm encodingStyle: http://schemas.xmlsoap.org/soap/encoding/ message: create_contactRequest parts: user_name: xsd:string password: xsd:string first_name: xsd:string last_name: xsd:string email_address: xsd:stringOutput: use: encoded namespace: http://www.sugarcrm.com/sugarcrm encodingStyle: http://schemas.xmlsoap.org/soap/encoding/ message: create_contactResponse parts: return: xsd:stringNamespace: http://www.sugarcrm.com/sugarcrmTransport: http://schemas.xmlsoap.org/soap/httpDocumentation: </pre> Even more detail can be had by inspecting the service. <source lang="php">$interestedModules = array('Accounts', 'Contacts'); foreach ($interestedModules as $module_name) { $get_module_fields_params = array ( 'session' => $session_id, 'module_name' => $module_name ); $result = $soapclient->call('get_module_fields', $get_module_fields_params); print "\n $module_name fields:<br />\n<pre>\n"; var_export ($result); print "\n</pre>\n";}</source> ===Accounts fields: === <source lang="php">array ( 'module_name' => 'Accounts', 'module_fields' => array ( 0 => array ( 'name' => 'id', 'type' => 'id', 'label' => 'ID', 'required' => 0, 'options' => array ( ), ), 1 => array ( 'name' => 'name', 'type' => 'name', 'label' => 'Name:', 'required' => 1, 'options' => array ( ), ), 2 => array ( 'name' => 'date_entered', 'type' => 'datetime', 'label' => 'Date Entered:', 'required' => 0, 'options' => array ( ), ), 3 => array ( 'name' => 'date_modified', 'type' => 'datetime', 'label' => 'Date Modified:', 'required' => 0, 'options' => array ( ), ), 4 => array ( 'name' => 'modified_user_id', 'type' => 'assigned_user_name', 'label' => 'Modified By Id', 'required' => 0, 'options' => array ( ), ), 5 => array ( 'name' => 'modified_by_name', 'type' => 'assigned_user_name', 'label' => 'Modified By Id', 'required' => 0, 'options' => array ( ), ), 6 => array ( 'name' => 'created_by', 'type' => 'assigned_user_name', 'label' => 'Created By Id', 'required' => 0, 'options' => array ( ), ), 7 => array ( 'name' => 'created_by_name', 'type' => 'assigned_user_name', 'label' => 'Created By Id', 'required' => 0, 'options' => array ( ), ), 8 => array ( 'name' => 'description', 'type' => 'text', 'label' => 'Description:', 'required' => 0, 'options' => array ( ), ), 9 => array ( 'name' => 'deleted', 'type' => 'bool', 'label' => 'Deleted', 'required' => 0, 'options' => array ( ), ), 10 => array ( 'name' => 'assigned_user_id', 'type' => 'relate', 'label' => 'Assigned User:', 'required' => 0, 'options' => array ( ), ), 11 => array ( 'name' => 'assigned_user_name', 'type' => 'relate', 'label' => 'Assigned to have changed with the addition :', 'required' => 0, 'options' => array ( ), ), 12 => array ( 'name' => 'account_type', 'type' => 'enum', 'label' => 'Type:', 'required' => 0, 'options' => array ( 0 => array ( 'name' => '', 'value' => '', ), 1 => array ( 'name' => 'Analyst', 'value' => 'Analyst', ), 2 => array ( 'name' => 'Competitor', 'value' => 'Competitor', ), 3 => array ( 'name' => 'Customer', 'value' => 'Customer', ), 4 => array ( 'name' => 'Integrator', 'value' => 'Integrator', ), 5 => array ( 'name' => 'Investor', 'value' => 'Investor', ), 6 => array ( 'name' => 'Partner', 'value' => 'Partner', ), 7 => array ( 'name' => 'Press', 'value' => 'Press', ), 8 => array ( 'name' => 'Prospect', 'value' => 'Prospect', ), 9 => array ( 'name' => 'Reseller', 'value' => 'Reseller', ), 10 => array ( 'name' => 'Other', 'value' => 'Other', ), ), ), 13 => array ( 'name' => 'industry', 'type' => 'enum', 'label' => 'Industry:', 'required' => 0, 'options' => array ( 0 => array ( 'name' => '', 'value' => '', ), 1 => array ( 'name' => 'Apparel', 'value' => 'Apparel', ), 2 => array ( 'name' => 'Banking', 'value' => 'Banking', ), 3 => array ( 'name' => 'Biotechnology', 'value' => 'Biotechnology', ), 4 => array ( 'name' => 'Chemicals', 'value' => 'Chemicals', ), 5 => array ( 'name' => 'Communications', 'value' => 'Communications', ), 6 => array ( 'name' => 'Construction', 'value' => 'Construction', ), 7 => array ( 'name' => 'Consulting', 'value' => 'Consulting', ), 8 => array ( 'name' => 'Education', 'value' => 'Education', ), 9 => array ( 'name' => 'Electronics', 'value' => 'Electronics', ), 10 => array ( 'name' => 'Energy', 'value' => 'Energy', ), 11 => array ( 'name' => 'Engineering', 'value' => 'Engineering', ), 12 => array ( 'name' => 'Entertainment', 'value' => 'Entertainment', ), 13 => array ( 'name' => 'Environmental', 'value' => 'Environmental', ), 14 => array ( 'name' => 'Finance', 'value' => 'Finance', ), 15 => array ( 'name' => 'Government', 'value' => 'Government', ), 16 => array ( 'name' => 'Healthcare', 'value' => 'Healthcare', ), 17 => array ( 'name' => 'Hospitality', 'value' => 'Hospitality', ), 18 => array ( 'name' => 'Insurance', 'value' => 'Insurance', ), 19 => array ( 'name' => 'Machinery', 'value' => 'Machinery', ), 20 => array ( 'name' => 'Manufacturing', 'value' => 'Manufacturing', ), 21 => array ( 'name' => 'Media', 'value' => 'Media', ), 22 => array ( 'name' => 'Not For Profit', 'value' => 'Not For Profit', ), 23 => array ( 'name' => 'Recreation', 'value' => 'Recreation', ), 24 => array ( 'name' => 'Retail', 'value' => 'Retail', ), 25 => array ( 'name' => 'Shipping', 'value' => 'Shipping', ), 26 => array ( 'name' => 'Technology', 'value' => 'Technology', ), 27 => array ( 'name' => 'Telecommunications', 'value' => 'Telecommunications', ), 28 => array ( 'name' => 'Transportation', 'value' => 'Transportation', ), 29 => array ( 'name' => 'Utilities', 'value' => 'Utilities', ), 30 => array ( 'name' => 'Other', 'value' => 'Other', ), ), ), 14 => array ( 'name' => 'annual_revenue', 'type' => 'varchar', 'label' => 'Annual Revenue:', 'required' => 0, 'options' => array ( ), ), 15 => array ( 'name' => 'phone_fax', 'type' => 'phone', 'label' => 'Fax:', 'required' => 0, 'options' => array ( ), ), 16 => array ( 'name' => 'billing_address_street', 'type' => 'varchar', 'label' => 'Billing Street:', 'required' => 0, 'options' => array ( ), ), 17 => array ( 'name' => 'billing_address_city', 'type' => 'varchar', 'label' => 'Billing City:', 'required' => 0, 'options' => array ( ), ), 18 => array ( 'name' => 'billing_address_state', 'type' => 'varchar', 'label' => 'Billing State:', 'required' => 0, 'options' => array ( ), ), 19 => array ( 'name' => 'billing_address_postalcode', 'type' => 'varchar', 'label' => 'Billing Postal Code:', 'required' => 0, 'options' => array ( ), ), 20 => array ( 'name' => 'billing_address_country', 'type' => 'varchar', 'label' => 'Billing Country:', 'required' => 0, 'options' => array ( ), ), 21 => array ( 'name' => 'rating', 'type' => 'varchar', 'label' => 'Rating:', 'required' => 0, 'options' => array ( ), ), 22 => array ( 'name' => 'phone_office', 'type' => 'phone', 'label' => 'Phone Office:', 'required' => 0, 'options' => array ( ), ), 23 => array ( 'name' => 'phone_alternate', 'type' => 'phone', 'label' => 'Alternate Phone:', 'required' => 0, 'options' => array ( ), ), 24 => array ( 'name' => 'website', 'type' => 'varchar', 'label' => 'Website:', 'required' => 0, 'options' => array ( ), ), 25 => array ( 'name' => 'ownership', 'type' => 'varchar', 'label' => 'Ownership:', 'required' => 0, 'options' => array ( ), ), 26 => array ( 'name' => 'employees', 'type' => 'num', 'label' => 'Employees:', 'required' => 0, 'options' => array ( ), ), 27 => array ( 'name' => 'ticker_symbol', 'type' => 'varchar', 'label' => 'Ticker Symbol:', 'required' => 0, 'options' => array ( ), ), 28 => array ( 'name' => 'shipping_address_street', 'type' => 'varchar', 'label' => 'Shipping Street:', 'required' => 0, 'options' => array ( ), ), 29 => array ( 'name' => 'shipping_address_city', 'type' => 'varchar', 'label' => 'Shipping City:', 'required' => 0, 'options' => array ( ), ), 30 => array ( 'name' => 'shipping_address_state', 'type' => 'varchar', 'label' => 'Shipping State:', 'required' => 0, 'options' => array ( ), ), 31 => array ( 'name' => 'shipping_address_postalcode', 'type' => 'varchar', 'label' => 'Shipping Postal Code:', 'required' => 0, 'options' => array ( ), ), 32 => array ( 'name' => 'shipping_address_country', 'type' => 'varchar', 'label' => 'Shipping Country:', 'required' => 0, 'options' => array ( ), ), 33 => array ( 'name' => 'email1', 'type' => 'varchar', 'label' => 'Email:', 'required' => 0, 'options' => array ( ), ), 34 => array ( 'name' => 'parent_id', 'type' => 'id', 'label' => 'Parent Account ID', 'required' => 0, 'options' => array ( ), ), 35 => array ( 'name' => 'sic_code', 'type' => 'varchar', 'label' => 'SIC Code:', 'required' => 0, 'options' => array ( ), ), 36 => array ( 'name' => 'account_name', 'type' => 'relate', 'label' => 'Account Name:', 'required' => 0, 'options' => array ( ), ), 37 => array ( 'name' => 'parent_name', 'type' => 'relate', 'label' => 'Member of a version number:', 'required' => 0, 'options' => array ( ), ), 38 => array ( 'name' => 'campaign_id', so you must be careful about what example you use 'type' => 'id', 'label' => 'Campaign ID', 'required' => 0, 'options' => array ( ), ), ), 'error' => '', and generally rely on the )</source> === Contacts fields: ===<source lang="php">array ( 'module_name' => 'Contacts', 'module_fields' => array ( 0 => array ( 'name' => 'id', 'type' => 'id', 'label' => 'ID:', 'required' => 0, 'options' => array ( ), ), 1 => array ( 'name' => 'date_entered', 'type' => 'datetime', 'label' => 'Date Created', 'required' => 0, 'options' => array ( ), ), 2 => array ( 'name' => 'date_modified', 'type' => 'datetime', 'label' => 'Date Modified:', 'required' => 0, 'options' => array ( ), ), 3 => array ( 'name' => 'modified_user_id', 'type' => 'assigned_user_name', 'label' => 'Modified By Id', 'required' => 0, 'options' => array ( ), ), 4 => array ( 'name' => 'modified_by_name', 'type' => 'assigned_user_name', 'label' => 'Modified By Id', 'required' => 0, 'options' => array ( ), ), 5 => array ( 'name' => 'created_by', 'type' => 'assigned_user_name', 'label' => 'Created By Id', 'required' => 0, 'options' => array ( ), ), 6 => array ( 'name' => 'created_by_name', 'type' => 'assigned_user_name', 'label' => 'Created By Id', 'required' => 0, 'options' => array ( ), ), 7 => array ( 'name' => 'description', 'type' => 'text', 'label' => 'Description:', 'required' => 0, 'options' => array ( ), ), 8 => array ( 'name' => 'deleted', 'type' => 'bool', 'label' => 'Deleted', 'required' => 0, 'options' => array ( ), ), 9 => array ( 'name' => 'assigned_user_id', 'type' => 'relate', 'label' => 'Assigned User', 'required' => 0, 'options' => array ( ), ), 10 => array ( 'name' => 'assigned_user_name', 'type' => 'relate', 'label' => 'Assigned to be the definitive :', 'required' => 0, 'options' => array ( ), ), 11 => array ( 'name' => 'salutation', 'type' => 'enum', 'label' => 'Salutation:', 'required' => 0, 'options' => array ( 0 => array ( 'name' => '', 'value' => '', ), 1 => array ( 'name' => 'Mr.', 'value' => 'Mr.', ), 2 => array ( 'name' => 'Ms.', 'value' => 'Ms.', ), 3 => array ( 'name' => 'Mrs.', 'value' => 'Mrs.', ), 4 => array ( 'name' => 'Dr.', 'value' => 'Dr.', ), 5 => array ( 'name' => 'Prof.', 'value' => 'Prof.', ), ), ), 12 => array ( 'name' => 'first_name', 'type' => 'varchar', 'label' => 'First Name:', 'required' => 0, 'options' => array ( ), ), 13 => array ( 'name' => 'last_name', 'type' => 'varchar', 'label' => 'Last Name:', 'required' => 1, 'options' => array ( ), ), 14 => array ( 'name' => 'title', 'type' => 'varchar', 'label' => 'Title:', 'required' => 0, 'options' => array ( ), ), 15 => array ( 'name' => 'department', 'type' => 'varchar', 'label' => 'Department:', 'required' => 0, 'options' => array ( ), ), 16 => array ( 'name' => 'do_not_call', 'type' => 'bool', 'label' => 'Do Not Call:', 'required' => 0, 'options' => array ( ), ), 17 => array ( 'name' => 'phone_home', 'type' => 'phone', 'label' => 'Home:', 'required' => 0, 'options' => array ( ), ), 18 => array ( 'name' => 'phone_mobile', 'type' => 'phone', 'label' => 'Mobile:', 'required' => 0, 'options' => array ( ), ), 19 => array ( 'name' => 'phone_work', 'type' => 'phone', 'label' => 'Office Phone:', 'required' => 0, 'options' => array ( ), ), 20 => array ( 'name' => 'phone_other', 'type' => 'phone', 'label' => 'Other Phone:', 'required' => 0, 'options' => array ( ), ), 21 => array ( 'name' => 'phone_fax', 'type' => 'phone', 'label' => 'Fax:', 'required' => 0, 'options' => array ( ), ), 22 => array ( 'name' => 'email1', 'type' => 'varchar', 'label' => 'Email:', 'required' => 0, 'options' => array ( ), ), 23 => array ( 'name' => 'email2', 'type' => 'varchar', 'label' => 'Other Email:', 'required' => 0, 'options' => array ( ), ), 24 => array ( 'name' => 'primary_address_street', 'type' => 'varchar', 'label' => 'Primary Address Street:', 'required' => 0, 'options' => array ( ), ), 25 => array ( 'name' => 'primary_address_city', 'type' => 'varchar', 'label' => 'Primary Address City:', 'required' => 0, 'options' => array ( ), ), 26 => array ( 'name' => 'primary_address_state', 'type' => 'varchar', 'label' => 'Primary Address State:', 'required' => 0, 'options' => array ( ), ), 27 => array ( 'name' => 'primary_address_postalcode', 'type' => 'varchar', 'label' => 'Primary Address Postal Code:', 'required' => 0, 'options' => array ( ), ), 28 => array ( 'name' => 'primary_address_country', 'type' => 'varchar', 'label' => 'Primary Address Country:', 'required' => 0, 'options' => array ( ), ), 29 => array ( 'name' => 'alt_address_street', 'type' => 'varchar', 'label' => 'Alternate Address Street:', 'required' => 0, 'options' => array ( ), ), 30 => array ( 'name' => 'alt_address_city', 'type' => 'varchar', 'label' => 'Alternate Address City:', 'required' => 0, 'options' => array ( ), ), 31 => array ( 'name' => 'alt_address_state', 'type' => 'varchar', 'label' => 'Alternate Address State:', 'required' => 0, 'options' => array ( ), ), 32 => array ( 'name' => 'alt_address_postalcode', 'type' => 'varchar', 'label' => 'Alternate Address Postal Code:', 'required' => 0, 'options' => array ( ), ), 33 => array ( 'name' => 'alt_address_country', 'type' => 'varchar', 'label' => 'Alternate Address Country:', 'required' => 0, 'options' => array ( ), ), 34 => array ( 'name' => 'assistant', 'type' => 'varchar', 'label' => 'Assistant:', 'required' => 0, 'options' => array ( ), ), 35 => array ( 'name' => 'assistant_phone', 'type' => 'phone', 'label' => 'Assistant Phone:', 'required' => 0, 'options' => array ( ), ), 36 => array ( 'name' => 'lead_source', 'type' => 'enum', 'label' => 'Lead Source:', 'required' => 0, 'options' => array ( 0 => array ( 'name' => '', 'value' => '', ), 1 => array ( 'name' => 'Cold Call', 'value' => 'Cold Call', ), 2 => array ( 'name' => 'Existing Customer', 'value' => 'Existing Customer', ), 3 => array ( 'name' => 'Self Generated', 'value' => 'Self Generated', ), 4 => array ( 'name' => 'Employee', 'value' => 'Employee', ), 5 => array ( 'name' => 'Partner', 'value' => 'Partner', ), 6 => array ( 'name' => 'Public Relations', 'value' => 'Public Relations', ), 7 => array ( 'name' => 'Direct Mail', 'value' => 'Direct Mail', ), 8 => array ( 'name' => 'Conference', 'value' => 'Conference', ), 9 => array ( 'name' => 'Trade Show', 'value' => 'Trade Show', ), 10 => array ( 'name' => 'Web Site', 'value' => 'Web Site', ), 11 => array ( 'name' => 'Word of mouth', 'value' => 'Word of mouth', ), 12 => array ( 'name' => 'Email', 'value' => 'Email', ), 13 => array ( 'name' => 'Campaign', 'value' => 'Campaign', ), 14 => array ( 'name' => 'Other', 'value' => 'Other', ), ), ), 37 => array ( 'name' => 'account_name', 'type' => 'relate', 'label' => 'Account Name:', 'required' => 0, 'options' => array ( ), ), 38 => array ( 'name' => 'account_id', 'type' => 'relate', 'label' => 'Account ID:', 'required' => 0, 'options' => array ( ), ), 39 => array ( 'name' => 'opportunity_role_fields', 'type' => 'relate', 'label' => 'Account Name:', 'required' => 0, 'options' => array ( ), ), 40 => array ( 'name' => 'reports_to_id', 'type' => 'id', 'label' => 'Reports to ID:', 'required' => 0, 'options' => array ( ), ), 41 => array ( 'name' => 'report_to_name', 'type' => 'relate', 'label' => 'Reports To:', 'required' => 0, 'options' => array ( ), ), 42 => array ( 'name' => 'birthdate', 'type' => 'date', 'label' => 'Birthdate:', 'required' => 0, 'options' => array ( ), ), 43 => array ( 'name' => 'portal_name', 'type' => 'varchar', 'label' => 'Portal Name:', 'required' => 0, 'options' => array ( ), ), 44 => array ( 'name' => 'portal_active', 'type' => 'bool', 'label' => 'Portal Active:', 'required' => 0, 'options' => array ( ), ), 45 => array ( 'name' => 'portal_app', 'type' => 'varchar', 'label' => 'Portal Application:', 'required' => 0, 'options' => array ( ), ), 46 => array ( 'name' => 'campaign_id', 'type' => 'id', 'label' => 'Campaign ID', 'required' => 0, 'options' => array ( ), ), 47 => array ( 'name' => 'campaign_name', 'type' => 'relate', 'label' => 'Campaign:', 'required' => 0, 'options' => array ( ), ), 48 => array ( 'name' => 'c_accept_status_fields', 'type' => 'relate', 'label' => 'Accept Status', 'required' => 0, 'options' => array ( ), ), 49 => array ( 'name' => 'm_accept_status_fields', 'type' => 'relate', 'label' => 'Accept Status', 'required' => 0, 'options' => array ( ), ), ), 'error' => '',)</source ;-)> 
== Some Issues discovered ==
4,558

edits

Navigation menu