Results 1 to 6 of 6

Thread: Proper Capitalization of Lead Data

  1. #1
    OBX
    OBX is offline Member
    Join Date
    Oct 2009
    Posts
    9

    Default Proper Capitalization of Lead Data

    Does anyone have any tips or pointers on how to programmatically try to scrub data as it's entered for leads. We have people who try to make it quicker to enter data so they just copy and paste and it ends up as all capitalized. But that doesn't work for when we want to export the data. We'd like to try and force it to proper capitalization, like John Smith not JOHN SMITH.

  2. #2
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Proper Capitalization of Lead Data

    Perhaps the easiest way would be to use a logic hook to apply proper casing on whichever fields require it. Check out the ucwords() PHP function: http://www.php.net/manual/en/function.ucwords.php
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  3. #3
    OBX
    OBX is offline Member
    Join Date
    Oct 2009
    Posts
    9

    Default Re: Proper Capitalization of Lead Data

    Thanks for pointing me in the right direction Angel. I didn't even know of Logic Hooks. Now I'm trying to set up a basic one

    PHP Code:
    <?php
    class Case_class
    {
        function 
    Case_method(&$bean$event$arguments=null)
        {
            if (
    $event != 'after_save') return;
            
    // Insert your custom logic between these comments
                    
    $first_name ucfirst(strtolower($first_name));
            
    // Insert your custom logic between these comments
        
    }
    }
    ?>
    And I've tried before_save, after_save, and process_record none of them seem to edit field. Is it something basic I'm missing?

  4. #4
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Proper Capitalization of Lead Data

    You need two files, the first is the definition of the hook and the second contains the actual code to be executed.

    Here is an example that will proper case the Last Name field of the Contacts module. To use it, create a file named logic_hooks.php with the following content and put it in the <sugar>/custom/modules/Contacts folder (create folder if necessary):

    Code:
    <?php
    
    $hook_version = 1;
    $hook_array = Array();
    $hook_array['before_save'][] = Array(1, 'ProperTest', 'custom/modules/Contacts/proper_case.php', 'ProperText', 'convertToProper');
    
    ?>
    Next, create another PHP file with the following contents and name it proper_case.php and place it in the same folder as where logic_hooks exists:

    Code:
    <?php
    
    /*************************************
    Project: Sample Hook to Proper Case a Field's Value
    Original Dev: Angel Magaņa, February 2010
    cheleguanaco[at]gmail.com
    
    Desc: Logic Hook Code for Proper Case Update 
    
    The contents of this file are governed by the GNU General Public License (GPL).
    A copy of said license is available here: http://www.gnu.org/copyleft/gpl.html
    This code is provided AS IS and WITHOUT WARRANTY OF ANY KIND.
    
    *************************************/
    
    class ProperText {
    
    	function convertToProper(&$bean, $event, $arguments) 
    	{
    		$bean->last_name = ucwords($bean->last_name);
    	}
    
    }
    
    ?>
    That should do it. Add a contact via the Create Contact link and make sure that proper casing is applied to the Last Name field after you save it.
    Last edited by Angel; 2010-02-18 at 04:01 PM.
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  5. #5
    OBX
    OBX is offline Member
    Join Date
    Oct 2009
    Posts
    9

    Default Re: Proper Capitalization of Lead Data

    Thank you so much for your help! It works great

    Just a note for others, in first set of php change proper_test.php to proper_case.php

    And if the information being entered is all upper case make it

    PHP Code:
    $bean->last_name ucwords(strtolower($bean->last_name)); 

  6. #6
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Proper Capitalization of Lead Data

    Oops...sorry about that. (proper_test.php)....Thanks for catching that..
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Keeping Custom Lead Data When Converting Lead -> Account
    By matthewfong in forum General Discussion
    Replies: 11
    Last Post: 2010-11-23, 02:38 PM
  2. Proper place for Web Services documentation?
    By cfjedimaster in forum Developer Help
    Replies: 5
    Last Post: 2009-03-24, 04:58 PM
  3. Accounts not showing proper user
    By ludvin in forum Help
    Replies: 3
    Last Post: 2009-01-26, 08:59 AM
  4. Proper procedure for upgrading 4.5f to 4.5g
    By asinglenet in forum Installation and Upgrade Help
    Replies: 1
    Last Post: 2006-12-18, 04:07 PM
  5. Proper Operation of email groups - help!!
    By nkendrick in forum Help
    Replies: 8
    Last Post: 2006-05-23, 02:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •