Importing contacts: Difference between revisions

m Text replacement - "<(\/?)source" to "<$1syntaxhighlight"
 
Line 70: Line 70:
Assume that we start with a spreadsheet that has column headings matching the 17 fields shown below.  Assume too that we want to capture all of the data in the sample.  (The owner of the data collected it for a reason and they wouldn't be too happy with a loss of data in a migration to a new application!)  I did not define new fields in the database, but I did correlate my data source to the Accounts and Contacts tables.  Because I had parsed the data source (spreadsheet or CSV file) for column headings, I simply exported that variable and then used it as a comment right in my code workup as I went.  What I mean is that I created a PHP (array) variable of the 17 field names, and then used the [http://php.net/var_export|var_export]() function to print it and copy/paste into a comment block so that I could mark up a plan for mapping those fields into fields in SugarCRM.
Assume that we start with a spreadsheet that has column headings matching the 17 fields shown below.  Assume too that we want to capture all of the data in the sample.  (The owner of the data collected it for a reason and they wouldn't be too happy with a loss of data in a migration to a new application!)  I did not define new fields in the database, but I did correlate my data source to the Accounts and Contacts tables.  Because I had parsed the data source (spreadsheet or CSV file) for column headings, I simply exported that variable and then used it as a comment right in my code workup as I went.  What I mean is that I created a PHP (array) variable of the 17 field names, and then used the [http://php.net/var_export|var_export]() function to print it and copy/paste into a comment block so that I could mark up a plan for mapping those fields into fields in SugarCRM.


<source lang="php">
<syntaxhighlight lang="php">
print '<pre>'; var_export ($arrFields); print '</pre>';
print '<pre>'; var_export ($arrFields); print '</pre>';
// copy and paste that output; then add comments about which fields go into which table
// copy and paste that output; then add comments about which fields go into which table
Line 93: Line 93:
   16 => 'ticker_symbol'// a:ticker_symbol                   
   16 => 'ticker_symbol'// a:ticker_symbol                   
)
)
</source>
</syntaxhighlight>


=== Using a Form ===
=== Using a Form ===
Line 107: Line 107:


; Tip: You can peer into the SugarCRM environment with a call to PHP's 'get_defined_vars()'.  This will give you some information about field maps etc.
; Tip: You can peer into the SugarCRM environment with a call to PHP's 'get_defined_vars()'.  This will give you some information about field maps etc.
<source lang="php">
<syntaxhighlight lang="php">
# temp.php to show a concise view of the variables defined in the config script
# temp.php to show a concise view of the variables defined in the config script
define('sugarEntry', true);
define('sugarEntry', true);
Line 186: Line 186:
                     [Website] => website
                     [Website] => website
                 )
                 )
</source>  
</syntaxhighlight>  


== Using SOAP ==
== Using SOAP ==
Line 259: Line 259:


Even more detail can be had by inspecting the service.
Even more detail can be had by inspecting the service.
<source lang="php">
<syntaxhighlight lang="php">
$get_available_modules_params = array (
$get_available_modules_params = array (
   'session' => $session_id,
   'session' => $session_id,
Line 267: Line 267:


// output:
// output:
</source>
</syntaxhighlight>
See [[Importing_contacts/sugar_modules]]
See [[Importing_contacts/sugar_modules]]


<source lang="php">
<syntaxhighlight lang="php">
$interestedModules = array('Accounts', 'Contacts');
$interestedModules = array('Accounts', 'Contacts');


Line 281: Line 281:
   print "\n $module_name fields:<br />\n<pre>\n"; var_export ($result); print "\n</pre>\n";
   print "\n $module_name fields:<br />\n<pre>\n"; var_export ($result); print "\n</pre>\n";
}
}
</source>
</syntaxhighlight>


===Accounts fields: ===
===Accounts fields: ===
Line 292: Line 292:


== Setting Records ==
== Setting Records ==
<source lang="php">
<syntaxhighlight lang="php">
// read in our data from source CSV file format
// read in our data from source CSV file format
$arrData = file('./account_contact_list.csv');
$arrData = file('./account_contact_list.csv');
Line 384: Line 384:
   */
   */
}
}
</source>
</syntaxhighlight>


== Conclusion ==
== Conclusion ==