Results 1 to 9 of 9

Thread: Automatic Sequential Numbering

  1. #1
    juniovalerio is offline Member
    Join Date
    Dec 2008
    Posts
    7

    Default Automatic Sequential Numbering

    Hi

    As Operations Manager for a huge project developer, my current task is to improve the SugarCRM system and one of the most important issues is the creation of a Sugar-based Project Archive.

    In the process of structuring an appropriate platform and list of entries, I find myself in the necessities of assigning to each contract input in the database, a tag, more precisely a progressive code of number to be given automatically by the system when I record the project. (0001, 0002, 0003, 0004....000N).


    I wonder if this function is already available, is somebody already using it for instance?

    Furthermore, how can I set the search criteria in Sugar to find a project using its numeric tag?

    Thanks in advance for your time and help.

    JV

  2. #2
    genius786's Avatar
    genius786 is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Karachi, Pakistan
    Posts
    131

    Smile Re: Automatic Sequential Numbering

    Hi,

    I think this sequential numbering is not available in sugarcrm.


    Best regards,
    SARFARAZ AHMED KHAN
    Karachi, Pakistan
    skype: genius_crystal
    genius_crystal@hotmail.com
    92-314-2595624

  3. #3
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: Automatic Sequential Numbering

    Quote Originally Posted by juniovalerio View Post
    In the process of structuring an appropriate platform and list of entries, I find myself in the necessities of assigning to each contract input in the database, a tag, more precisely a progressive code of number to be given automatically by the system when I record the project. (0001, 0002, 0003, 0004....000N).
    It is not 100% resilient because it is not atomic but this can quite easily be achieved with a custom field and a small bit of custom logic.

    Add a custom field project_number_c type integer.
    Then create a before_save logic hook that does
    PHP Code:
    if (empty($bean->project_number_c))
    {
         
    $query "select max(project_number_c)+1 as newnum from project_cstm";
         
    $res $bean->db->query($query);
         
    $row $bean->db->fetchByAssoc($res);
         
    $bean->project_number_c $row['newnum'];

    if you can risk (the small risk of) getting duplicates if two projects are saved in a very short time then this is your easiest solution. Otherwise you will have to declare the field project_number_c as auto increment in the database after sugar created it.
    --


    Marnus van Niekerk

    There are only 10 types of people in the world
    those who can read binary and those who don't

    Modules:
    CE Teams - Upgrade safe teams module for Community Edition
    FieldACL - Field Level Access Control for Community Edition
    EditLogicHooks - Create and edit Logic Hooks from the Admin GUI
    FlexibleChartDashlet - Display any data in a Dashlet Chart
    DocumentThumbnails - Thumbnails for Documents module

    Many questions can be answered by reading the Developers Manual

  4. #4
    daniel.passarini's Avatar
    daniel.passarini is offline Sugar Community Member
    Join Date
    Apr 2006
    Location
    São Paulo - SP / Brasil
    Posts
    80

    Default Re: Automatic Sequential Numbering

    Also, you can try a MySQL solution, by creating an auto_increment column, so you dont need to customize sugarcrm.
    here is a simple example:
    PHP Code:
    ALTER TABLE `your_tableADD `project_numberINT NOT NULL AUTO_INCREMENT 
    Daniel de Carvalho Passarini

    "Fascinating" - Dr. Spock

  5. #5
    Rudi Mentär is offline Senior Member
    Join Date
    Sep 2008
    Posts
    157

    Default Re: Automatic Sequential Numbering

    I have an auto_increment, but it increments also on an update?
    How can i achive, that the field only increments when adding NEW Data and not when CHANGING Data?

  6. #6
    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: Automatic Sequential Numbering

    In the last post by Marnus van Niekerk

    Add a code into logic_hook function to identify if this record is a new one or an old one.
    This way you can conditionally increment.

    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.

  7. #7
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: Automatic Sequential Numbering

    Do not try to alter the db via direct SQL. Sugar will still try to update the field on a save.

    Tell Sugar it's a auto_increment field, explained here: http://www.sugarcrm.com/wiki/index.php?title=Int.
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  8. #8
    Rudi Mentär is offline Senior Member
    Join Date
    Sep 2008
    Posts
    157

    Default Re: Automatic Sequential Numbering

    i heard that with logic hooks it might be able to cause lost updates?

  9. #9
    labanjohnson is offline Sugar Community Member
    Join Date
    Jul 2007
    Location
    Houston, TX
    Posts
    139

    Default Re: Automatic Sequential Numbering

    How could we have forgotten the all important Account Number?!
    Laban Johnson
    SugarCE User, Idealist
    Open Source and Social Media Enthusiast, Social Entrepreneur
    Twitter: http://www.twitter.com/labanjohnson
    Facebook LinkedIn
    Home page: http://www.LabanJohnson.com

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Sequential column
    By ServerStorm in forum Developer Help
    Replies: 3
    Last Post: 2008-10-03, 07:15 PM
  2. Numbering the leads - Urgent help needed
    By kanchan in forum Developer Help
    Replies: 15
    Last Post: 2008-02-29, 10:13 AM
  3. sequential messages
    By Dale Thomas in forum Marketing/Campaign Management
    Replies: 1
    Last Post: 2006-12-05, 02:08 AM
  4. Automatic Account numbering/reference?
    By Rilliam in forum General Discussion
    Replies: 2
    Last Post: 2006-02-14, 12:31 AM
  5. letter writing (numbering)
    By albatroz in forum General Discussion
    Replies: 0
    Last Post: 2005-06-15, 03:16 PM

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
  •