Changes

Jump to navigation Jump to search
1,756 bytes removed ,  01:08, 10 July 2008
no edit summary
== Introduction ==
[http://www.sugarcrm.com SugarCRM] is the world's leading Customer Relationship Management (CRM) software available with complete freedom under the GPL license. For companies that want more than freedom, SugarCRM Inc, fully backs the product with expert support, service, training and customization. SugarCRM offers several deployment options, including on-demand, on-premise and appliance-based solutions to suit customers' security, integration and configuration needs. Because CRM software captures the varied relationships between a company and it's sources of revenue, most businesses really stand to benefit from the intelligence provided by a CRM system. All companies already have 'ad-hoc' methods to track leads, contacts, customer accounts and the company interactions with these (e.g. spreadsheets, lists and email records). They may even have organized CRM solutions in place. Either way, once you decide to adopt an open and standards-based solution like SugarCRM, your first order of business will be to load it with your existing data. SugarCRM has importing (and exporting) utilities that make it easy to do this, so these wizards will not be the focus of this article. Instead, we'll focus on programmatic interaction with the system.
Once == Introduction ==Typically a company will deploy the CRM system is deployed, a company and will also typically want to create one or more pipelines which act as conduits to capture new account, and contact information. This article will show how easy it can be to establish a web service, using [http://en.wikipedia.org/wiki/SOAP SOAP] to add contacts and accounts to your [[Install SugarCRM|SugarCRM installation]]. As an example scenario, let's suppose that a conference organizer wants to offer a sign-up sheet on their existing website. The existing website could be a [http://drupal.org Drupal] content management system (CMS) which not only manages the conference, but also adds company and individual contact details to the SugarCRM system via the web service. The details on creating the form for the capture are beyond the scope of this article but the capture routines could easily handle a form input (HTTP POST) just as easily as we read input from a file . Again our focus for today will be on the plumbing of the interaction with the SOAP server.
== Goal ==
Import records into SugarCRM without using existing import wizards but rather by writing a tool in [http://en.wikipedia.org/wiki/PHP PHP] to do the work. Records should go into Accounts and Contacts, while creating a relationship between the two.
 
== Download and Install SugarCRM ==
SugarCRM provides easy stack installers which make trying the system as close to a one-click operation as possible. However, in the many scenarios the developer or system administrator will want to install into an existing infrastructure so we'll assume that approach.
# Visit the [http://sugarcrm.com SugarCRM homepage], and click the top navbar link to "Sugar Open Source"
# Skip the "Wizard" and go right to the "Download Page" because you know what you're doing and also have a pre-existing setup of Linux, Apache MySQL and PHP
# Download SugarCE-5.0.0e.zip (production release) or the later available production release (getting only the application).
# Visit the recommended "Installation" instructions page at http://www.sugarforge.org/content/installation/
# Install SugarCRM according to the instructions. Note: I immediately ran into trouble because the instructions did say to chmod 766 all files that needed to be writable by the web_user. This command renders the directories non-executable which manifests in include errors because the web user (www-data) can not see into those directories (to find includes). The following snippet is a fix:
<source lang="bash">
# find directories in the ./crm path and change the mode on them so that all users can execute (see into) the directory
find ./crm/ -type d |xargs chmod a+x
</source>
 
There is one more 'gotcha' that I ran into with the installation. The application wants to create a .htaccess file (which doesn't exist in the distribution and would not necessarily be writable to the web user.) As a failsafe, the .htaccess content is printed to the screen in the installer. However it doesn't properly display (lacking newline characters) so the content is not suitable for copy and paste into the file. I resorted to the source which generates the .htaccess content, and used that. An alternative is to simply touch and chmod 777 a .htaccess file '''prior''' to running the installer; and then chmod'ing it go=r after install.
== Requirements ==
My self-imposed requirement was 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 my the sample assuming the . (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 did not define new fieldsin the database, but I did 'draw' a map of correlate my data source and how it corresponds to the data definition of 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">
The form can be found in the "examples" directory in the source. Note: the example did not work as an application entry point (because even though it defined ('sugarEntry', true); there was also an IF that pre-empted that definition -- because requests inside the SugarCRM install directory will automatically bootstrap the SugarCRM system). To work around this, either put the example form outside the application directory or define sugarEntry as true ''without'' the 'if' conditional. Using the lead capture form is illustrated at http://www.sugarcrm.com/wiki/index.php?title=Creating_a_lead_capture_form_for_your_website
If your needs are more complex than the simple example, you can learn more by looking at the modules dealing with Import (dataMaps), the database abstraction layer (SugarBeans and VarDefs) or the database directly to get a clearer picture of everything going on in the SugarCRM system.
=== Use the Source Luke ===
/**
// alternately, if you have both ids, you can set the relationship for these two records using use set_relationship
$set_relationship_params = array(
'session' => $session_id,
== Conclusion ==
In this article we've shown how the SugarCRM system is enterprise-ready in that it has a fully built SOAP service that can be used to integrate the system with one or more 'front-end' websites or applications for data capture. With important information easily added to the system, it allows the company to focus resources on managing the most valuable assets. Due to SugarCRM's open source nature and standards support, it's easy to extend and integrate the system with other existing or new infrastructure components. In future articles, we'll take a look at still more interesting integrations with SugarCRM such as collaboration and , document management and knowledge management.
4,558

edits

Navigation menu