Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Leveraging Geographic
  Data in SugarCRM
About the Speaker
                        Asa
                        Kusuma
• Intern at Milsoft Utility Solutions
• Sopho...
Geographic Data:
What’s the Big Deal?
photo by gerlos




Know Your Customers
Reaching the End Goal

New     New CRM           Create
Data    Capabilities      Visuals



Old      Filter         Insig...
The End Goal Expanded
                            photo by eBeam



•   Target customers

•   Streamline analysis

•   Get...
photo by eBeam




Concept is simple
photo by Dizzy Girl




Implementation is Messy
The Case Study
About Milsoft
•   We make software for
    utility companies

•   Headquarters in
    Abilene, TX

•   Over 1,000 customer...
Our needs at Milsoft
• Send geographic-sensitive data to customers
 • Marketing
 • Workshops
• Inform decision makers
• St...
Bad
Good
The Old Way
1. Export SugarCRM data
2. Cleanup data
3. Import data into 3rd party software
4. Filter data or generate visu...
The New Way

1. Filter data or create visual in SugarCRM
2. Laugh at people doing it the old way
Steps to Success
1. Extend your data
  • Add coordinates to Accounts
2. Create data filtering capabilities
  • Add geograph...
Solutions vs. Hacks
SIMPLICITY
Blend In
Guidelines

• Permanent, scalable solutions, not hacks
• If it’s not simple, it won’t be used
• Insert new features into e...
Checkout the Code
asakusuma.com/sugarcon
Step 1:
Add Geographic Data
• Get a Google Maps API Key
• Create custom fields
• Create script
 • Connect to database
 • Ad...
Create Custom Fields
Admin > Studio > Accounts > Fields > Add Field

 • Add fields to store latitude & longitude
 • Datatyp...
Create Script
• Connect to SugarCRM database
 • Invoke config.php (don’t hardcode)
• Retrieve and loop through Accounts
 • ...
Get coordinates


Save coordinates
Now What?

• Accounts with an address have coordinates
• Do stuff with the coordinates
 • Filter Accounts with Reports
 • ...
Filtering in Reports
• Select Accounts within a certain distance of
  a postal code
• Add functionality to Reports
Code the Filter

1. Create the label string
2. Associate the label string with a function
3. Create the function
4. Add th...
Create the String Label




modules/Reports/language/en_us.lang.php
Associate Label with Function




      modules/Reports/templates/
    templates_modules_defs_js.php
Create the Function



                           Get postal code coordinates
                                          Fi...
Add Extra Text Inputs




                                  Add inputs




  include/javascript/reports.js
Add Extra Text Inputs (cont.)
                                  2 new arguments

                             Set default ...
Force the JOIN
                          Link to accounts_cstm




• Custom fields are stored in accounts_cstm
• JOIN combi...
Radius
     Distance   Radius Center
                (Postal Code)



The Result
Make a Simple Map
Code the Map

1. Connect to the database
2. Pull Account coordinates
3. Pass data from PHP to JavaScript
4. Plot points on...
Setup the Map



                   Connect to database




      Import jQuery and Google Map stuff

map.php (in the root...
Display the Map


                     Echo out data as
                     a JavaScript array


                   Plot ...
The Result
nifty link




Put it all together
Data Path
          Report ID
Report                           Map


                      Report            Data
        ...
Create Query Retrieval Function
                                 Check for
                            Lat & Long columns
...
Link From Report to Map




                    Create link

modules/Reports/Reports.php (execute_query())
Prepare the Data for the Map




                              Receive Report ID

Create a Report
                    Prod...
Display the Map

                 Package account
                    as a point



                 Initialize Map

     ...
click here...




Put it all together
The Final Result
Try This At Home
• Protect your data
• Work out the kinks
 • Issues with editing Reports
 • Issues with multi-module Repor...
photo by gerlos




Know Your Customers
Leveraging Geographic Data in SugarCRM
Upcoming SlideShare
Loading in …5
×

Leveraging Geographic Data in SugarCRM

3,826 views

Published on

Presentation given at SugarCON 2010.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Leveraging Geographic Data in SugarCRM

  1. 1. Leveraging Geographic Data in SugarCRM
  2. 2. About the Speaker Asa Kusuma • Intern at Milsoft Utility Solutions • Sophomore at Abilene Christian University • Twitter: asakusuma • www.asakusuma.com
  3. 3. Geographic Data: What’s the Big Deal?
  4. 4. photo by gerlos Know Your Customers
  5. 5. Reaching the End Goal New New CRM Create Data Capabilities Visuals Old Filter Insight into Data Data Customer Base
  6. 6. The End Goal Expanded photo by eBeam • Target customers • Streamline analysis • Get the “Big Picture” • Look good in meetings • Capitalize on data
  7. 7. photo by eBeam Concept is simple
  8. 8. photo by Dizzy Girl Implementation is Messy
  9. 9. The Case Study
  10. 10. About Milsoft • We make software for utility companies • Headquarters in Abilene, TX • Over 1,000 customers, US + International photo by philipbouchard
  11. 11. Our needs at Milsoft • Send geographic-sensitive data to customers • Marketing • Workshops • Inform decision makers • Streamline meetings • Do it all in SugarCRM
  12. 12. Bad
  13. 13. Good
  14. 14. The Old Way 1. Export SugarCRM data 2. Cleanup data 3. Import data into 3rd party software 4. Filter data or generate visual 5. Cross fingers 6. Import data back into SugarCRM
  15. 15. The New Way 1. Filter data or create visual in SugarCRM 2. Laugh at people doing it the old way
  16. 16. Steps to Success 1. Extend your data • Add coordinates to Accounts 2. Create data filtering capabilities • Add geographic filters for Reports 3. Create visuals • Link your Accounts with Google Maps • Link your Reports with Google Maps
  17. 17. Solutions vs. Hacks
  18. 18. SIMPLICITY
  19. 19. Blend In
  20. 20. Guidelines • Permanent, scalable solutions, not hacks • If it’s not simple, it won’t be used • Insert new features into existing workflow • Complement and extend existing features
  21. 21. Checkout the Code asakusuma.com/sugarcon
  22. 22. Step 1: Add Geographic Data • Get a Google Maps API Key • Create custom fields • Create script • Connect to database • Add coordinates to each account • Run script (takes a long time)
  23. 23. Create Custom Fields Admin > Studio > Accounts > Fields > Add Field • Add fields to store latitude & longitude • Datatype: Decimal • Uncheck “Required Field” • Check “Reportable” • Populate fields using address + Google Maps
  24. 24. Create Script • Connect to SugarCRM database • Invoke config.php (don’t hardcode) • Retrieve and loop through Accounts • Send address to Google Maps • Receive Latitude and Longitude • Record coordinates
  25. 25. Get coordinates Save coordinates
  26. 26. Now What? • Accounts with an address have coordinates • Do stuff with the coordinates • Filter Accounts with Reports • Put your Accounts on a map • Put your filtered Accounts on a map
  27. 27. Filtering in Reports • Select Accounts within a certain distance of a postal code • Add functionality to Reports
  28. 28. Code the Filter 1. Create the label string 2. Associate the label string with a function 3. Create the function 4. Add the extra text inputs 5. Force a JOIN with accounts_cstm
  29. 29. Create the String Label modules/Reports/language/en_us.lang.php
  30. 30. Associate Label with Function modules/Reports/templates/ templates_modules_defs_js.php
  31. 31. Create the Function Get postal code coordinates Filter query include/generic/SugarWidgets/SugarWidgetReportField.php (queryFilterWithin_Radius())
  32. 32. Add Extra Text Inputs Add inputs include/javascript/reports.js
  33. 33. Add Extra Text Inputs (cont.) 2 new arguments Set default input size Add label include/javascript/reports.js (addFilterInputText())
  34. 34. Force the JOIN Link to accounts_cstm • Custom fields are stored in accounts_cstm • JOIN combines accounts and accounts_cstm modules/Reports/Reports.php (create_from())
  35. 35. Radius Distance Radius Center (Postal Code) The Result
  36. 36. Make a Simple Map
  37. 37. Code the Map 1. Connect to the database 2. Pull Account coordinates 3. Pass data from PHP to JavaScript 4. Plot points on the Google Map
  38. 38. Setup the Map Connect to database Import jQuery and Google Map stuff map.php (in the root directory)
  39. 39. Display the Map Echo out data as a JavaScript array Plot points on the map map.php (in the root directory)
  40. 40. The Result
  41. 41. nifty link Put it all together
  42. 42. Data Path Report ID Report Map Report Data ID Points Query Database
  43. 43. Create Query Retrieval Function Check for Lat & Long columns Add Lat & Long columns Build Query Return Query modules/Reports/Reports.php (execute_query())
  44. 44. Link From Report to Map Create link modules/Reports/Reports.php (execute_query())
  45. 45. Prepare the Data for the Map Receive Report ID Create a Report Produce MySQL query modules/Reports/map.php
  46. 46. Display the Map Package account as a point Initialize Map Plot data on Map modules/Reports/map.php
  47. 47. click here... Put it all together
  48. 48. The Final Result
  49. 49. Try This At Home • Protect your data • Work out the kinks • Issues with editing Reports • Issues with multi-module Reports • Code Snippets at: http://www.asakusuma.com/sugarcon • Be the envy of your next meeting
  50. 50. photo by gerlos Know Your Customers

×