Results 1 to 9 of 9

Thread: Unique Number Incremental

  1. #1
    DanBrown is offline Senior Member
    Join Date
    Jul 2008
    Posts
    95

    Question Unique Number Incremental

    Hi im using :
    MySQL client version: 5.0.45
    Sugar 5.0.0g

    I have managed to create a unique number that auto increments for my accounts, however is it possible to define a defualt numbering format instead of it going up like 1, 2, 3, 4 etc, can a default format be set like A00001, A00002, A00003?

    Many Thanks

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Unique Number Incremental

    Hi Dan.

    1. You create the custom field in accounts (text field);
    2. You create a logic_hook before_save for Accounts. This logic_hook can define the next value based on the last value saved into database. For this use a query to find out the last auto incremental value;
    3. You use the function sprintf to generate the next value formated.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    DanBrown is offline Senior Member
    Join Date
    Jul 2008
    Posts
    95

    Default Re: Unique Number Incremental

    How do i create a logic hook, can it be done in PHP?

  4. #4
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Unique Number Incremental

    Hi Dan.

    There are articles into Sugar Wiki which can help you how to create logic_hook.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  5. #5
    DanBrown is offline Senior Member
    Join Date
    Jul 2008
    Posts
    95

    Thumbs up Re: Unique Number Incremental

    Thanks Andre

  6. #6
    DanBrown is offline Senior Member
    Join Date
    Jul 2008
    Posts
    95

    Default Re: Unique Number Incremental

    do i need to build an installer for this logic hook?
    can you confirm i am looking at the correct Wiki article:
    http://www.sugarcrm.com/wiki/index.p...r_Custom_Logic

  7. #7
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Unique Number Incremental

    Hi Dan,

    No, you don't need to create an installer for the logic_hook.

    You just have to:
    1. create the file custom/modules/<ModuleName>/logic_hooks.php
    2. Add inside this file the enough array to call the method in the Logic Hook Class
    3. Create the Class
    4. Create the method will be called by logic_hook. This method will perform the custom logic.

    An example of the Logic Hook Class:



    PHP Code:
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class 
    UserHook {
        function 
    setSearchFields(&$focus$event$arguments) {
            global 
    $current_user;
            
            if(
    $focus->id == $current_user->id && isset($_REQUEST['action'])) {
                if(
    $_REQUEST['module'] == 'UP2_placements') {
                    
    //cleaning the template HTML every time
                    //this is necessary in non-Developer mode because of the custom code in the check-boxes
                    
    require_once('modules/Administration/QuickRepairAndRebuild.php');
                    
                    
    $selected_actions = Array(=> 'clearTpls');
                    
    $modules = Array(=> 'UP2_placements');
                    
    $RepairAndClear = new RepairAndClear();
                    
    $RepairAndClear->repairAndClearAll($selected_actions$modules$autoexecute=false$show_output=false);
                    
    //end this is necessary in non-Developer mode because of the custom code in the check-boxes
                
    }
                if(
    $_REQUEST['action'] == 'AdDeliveryImportView') {
                    
    $this->setAdDeliveryImportSearchFields();
                } else if(
    $_REQUEST['action'] == 'SelectInventoryView') {
                    
    $this->setSelectInventorySearchFields();
                } else if(
    $_REQUEST['action'] == 'MonthEndValidationView') {
                    
    $this->setMonthEndValidationSearchFields();
                }
            }
        }

    Best regards.
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  8. #8
    DanBrown is offline Senior Member
    Join Date
    Jul 2008
    Posts
    95

    Thumbs up Re: Unique Number Incremental

    Thanks André

    Ill give it a go, just so i know what does the PHP code you pasted here actually do, just so i can reference it with the one i try to create.

  9. #9
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,597

    Default Re: Unique Number Incremental

    In this thread http://www.sugarcrm.com/forums/showthread.php?t=27290
    I described such a solution.
    Harald Kuske
    Pre-Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Integrating a unique field with Sugar
    By tomkerswill in forum Help
    Replies: 7
    Last Post: 2012-01-25, 03:44 AM
  2. Replies: 4
    Last Post: 2008-05-29, 07:52 AM
  3. Auto incremental number
    By gjlando in forum Help
    Replies: 4
    Last Post: 2008-05-07, 06:49 PM
  4. Replies: 3
    Last Post: 2008-01-20, 11:13 AM
  5. REQ: tracking number
    By Jeroen in forum General Discussion
    Replies: 3
    Last Post: 2005-03-31, 12:30 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
  •