Results 1 to 5 of 5

Thread: auto-increment id

  1. #1
    jcb23 is offline Sugar Community Member
    Join Date
    Sep 2007
    Posts
    70

    Default auto-increment id

    Windows XP and Vista
    Sugar 5.1.0b
    Apache 2.2.4
    PHP: 5.2.3-1ubuntu6.3
    MySQL Server: 5.0.45-1ubuntu3.3

    I need an id to show for contacts, opportunities, accounts and leads that is not the really long id that is automatically associated with the record, but is a simple integer that auto-increments as records are created. The field should be one that our users can't edit, but only see and search by - basically its a surefire way to get a particular record.

    I've created the field identification_number_c and when we moved to the sugar database from our old database I plugged the old id numbers into this field and its working beautifully. The only problem is the auto increment from here on out. I can't seem to get the field to automatically increment (when a new record is created) starting from the highest number that's already in the field.

    Any suggestions?

    jcb23

  2. #2
    sugarcane is offline Sugar Community Member
    Join Date
    Apr 2005
    Location
    Chicago, IL
    Posts
    1,207

    Default Re: auto-increment id

    Hello,

    have you taken a look at this posting?: http://www.sugarcrm.com/forums/showt...ent+logic+hook
    Intelestream has a great deal of experience hosting and customizing the SugarCRM application. Our company is made up by former employees of SugarCRM, and together we have over 50 years of experience working with the application. To learn more about us, please visit our website at www.intelestream.net or contact us directly at 800-391-4055 or by email at info@intelestream.net

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

    Default Re: auto-increment id

    With
    ALTER TABLE tabname AUTO_INCREMENT = startvalue;

    you can set a start value for the auto íncrement function.
    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


  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: auto-increment id

    Quote Originally Posted by kuske View Post
    With
    ALTER TABLE tabname AUTO_INCREMENT = startvalue;

    you can set a start value for the auto íncrement function.
    The Kuske suggestion works pretty fine and you can persist this alter table code into module vardefs, just create an extended vardefs for the module adding a index for that field.
    Have a look in the cache/modules/Cases/Casevardefs.php

    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
    jcb23 is offline Sugar Community Member
    Join Date
    Sep 2007
    Posts
    70

    Default Re: auto-increment id

    Quote Originally Posted by andopes View Post
    The Kuske suggestion works pretty fine and you can persist this alter table code into module vardefs, just create an extended vardefs for the module adding a index for that field.
    Have a look in the cache/modules/Cases/Casevardefs.php

    Cheers
    Can you give me an example of that this code should look like? I tried using that Cases file as an example, but wasn't able to get it to work.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. auto increment value in field
    By pearsondan99 in forum Developer Help
    Replies: 18
    Last Post: 2009-06-26, 04:18 PM
  2. Auto Increment Integer Field
    By Spy123 in forum Developer Help
    Replies: 0
    Last Post: 2007-01-24, 10:02 AM
  3. How to make id auto increment
    By agvg in forum Developer Help
    Replies: 2
    Last Post: 2006-11-18, 07:37 AM
  4. Replies: 0
    Last Post: 2006-03-06, 07:41 AM
  5. Case Number Auto increment
    By jeipi in forum Help
    Replies: 0
    Last Post: 2005-06-16, 05:45 AM

Tags for this Thread

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
  •