Results 1 to 5 of 5

Thread: Auto incremental number

  1. #1
    gjlando is offline Junior Member
    Join Date
    Apr 2008
    Posts
    4

    Unhappy Auto incremental number

    Hi,
    I needed to create a new module similar to Cases.
    I did it succesfully except for the following: the Cases module has a field called case_number which is automatically increased by the system (it is not required as an input for the user).
    The new module I created, with the Issue template, has this field but it is not auto incremental, and I cannot find a type of field like that.
    Could anyone help me please?
    Thank you.
    Gabriela.

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

    Default Re: Auto incremental number

    The auto increment is accomplished at the database server level, not within Sugar.

    See here for info on how to apply the feature to your column: http://dev.mysql.com/doc/refman/5.0/...increment.html
    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
    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: Auto incremental number

    Hi, Gabriela.

    Did you run the quick repair and rebuild?
    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.

  4. #4
    ToniFatec is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    64

    Lightbulb Re: Auto incremental number

    You can also "force" a normal int field to became autonumber as you want to, plus you can obligate it begins with any size and/or add other characters (only in case it is a varchar in database).

    Because it is in a new module you can edit default Sugarbean->save() method by inheritance:

    PHP Code:
    function save($check_notify FALSE) {
            
    $this->setOrder();
            
    parent::save();
        }

        function 
    setOrder() {
            if (
    $this->id == ''){
                
    $query "SELECT order_number FROM my_module_name ORDER BY order_number DESC";
                
    $result $this->db->query($query,true,"");
                
    $row $this->db->fetchByAssoc($result);
                if(
    $row != ''){
                    
    $this->order_number = ($row['order_number'] + 1);
                }
            }
        } 

  5. #5
    hagay2386 Guest

    Default Re: Auto incremental number

    Hi Gabriela,
    I wish I would know the answer, but I don't.
    You can visit us on:

    http://www.elalmovers.com
    http://www.elalmoving.com
    Miami movers, movers in Miami

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 2008-01-20, 11:13 AM
  2. Replies: 0
    Last Post: 2006-10-20, 11:45 AM
  3. Case Number Auto increment
    By jeipi in forum Help
    Replies: 0
    Last Post: 2005-06-16, 05:45 AM
  4. 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
  •