Results 1 to 7 of 7

Thread: Something wrong with my auto increment ?

  1. #1
    dekleinemedia is offline A Prolific Poster
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    241

    Exclamation Something wrong with my auto increment ?

    Hi,

    I have a problem in my custom created "Accounts" module;
    I have created a logic hook for auto increment. When i want to create a new "account" i fill in the "name", and leave the "number" field empty so it automatically SHOULD create "0001". When i do this and i "save" it, it gives me back a blank page with the message "can't show page".

    BUT; when it is the first "account" and i fill in the "name" and fill in the "number" with any number it does save this account with number "0001'
    This is only with the first account, cause when account "0001' exists, and i create a new "account" where i leave the "number field' empty, it does save as "0002"

    How strange is this? And can someone please tell me what the solution is?

    Thanks very much!

    See screenshot

    Ps; Isn't is possible that when i go to "create account" it automatically fill in the "number field" with its (following) number ?
    Attached Images Attached Images  
    Kind regards,

    De Kleine Media


    SugarCRM CE v.5.2.0h
    Windows platform
    MySQL v.5.1
    phpMyAdmin - 2.11.2.2
    Apache Server v.2.0

  2. #2
    crmbalah is offline A Prolific Poster
    Join Date
    Mar 2009
    Location
    chennai
    Posts
    418

    Default Re: Something wrong with my auto increment ?

    HI
    remove the number field from this edit view, display only the detail view.

  3. #3
    dekleinemedia is offline A Prolific Poster
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    241

    Default Re: Something wrong with my auto increment ?

    Quote Originally Posted by crmbalah View Post
    HI
    remove the number field from this edit view, display only the detail view.
    Thanks, but i already tried that. When i remove the "number" field of my editview, i can't save the new account because it shows me an blank page with the message "can't show page".
    I think it something in my DB ? Can't figure out why...
    Kind regards,

    De Kleine Media


    SugarCRM CE v.5.2.0h
    Windows platform
    MySQL v.5.1
    phpMyAdmin - 2.11.2.2
    Apache Server v.2.0

  4. #4
    dekleinemedia is offline A Prolific Poster
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    241

    Lightbulb Re: Something wrong with my auto increment ?

    Quote Originally Posted by dekleinemedia View Post
    Thanks, but i already tried that. When i remove the "number" field of my editview, i can't save the new account because it shows me an blank page with the message "can't show page".
    I think it something in my DB ? Can't figure out why...
    Okay I figured out what the problem is/was; My custom field "number" wasn't a "required field". I have modified this, and deleted this "number" field from the editview.
    Now when i create a new "account" i only have to fill in the name, and after save it automatically gives this account the latest accountnumber.'

    If anyone had questions of how to do this auto-increment through logic_hook after save, just post your message here and i will try te help you

    Greetzz
    Kind regards,

    De Kleine Media


    SugarCRM CE v.5.2.0h
    Windows platform
    MySQL v.5.1
    phpMyAdmin - 2.11.2.2
    Apache Server v.2.0

  5. #5
    crmbalah is offline A Prolific Poster
    Join Date
    Mar 2009
    Location
    chennai
    Posts
    418

    Default Re: Something wrong with my auto increment ?

    Hi
    inside the logic hook you can write the query
    first get the max of count from the account number then increment the account number the update the account filed.

  6. #6
    dayao61 is offline Junior Member
    Join Date
    Jul 2009
    Posts
    1

    Default Re: Something wrong with my auto increment ?

    Quote Originally Posted by dekleinemedia View Post
    Okay I figured out what the problem is/was; My custom field "number" wasn't a "required field". I have modified this, and deleted this "number" field from the editview.
    Now when i create a new "account" i only have to fill in the name, and after save it automatically gives this account the latest accountnumber.'

    If anyone had questions of how to do this auto-increment through logic_hook after save, just post your message here and i will try te help you

    Greetzz
    Hi,

    Can you post an example code as how to do this especially the logic hook part?

    Thanks in advance.

  7. #7
    dekleinemedia is offline A Prolific Poster
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    241

    Default Re: Something wrong with my auto increment ?

    Quote Originally Posted by dayao61 View Post
    Hi,

    Can you post an example code as how to do this especially the logic hook part?

    Thanks in advance.
    Hi, this code worked for me.
    Attached Files Attached Files
    Kind regards,

    De Kleine Media


    SugarCRM CE v.5.2.0h
    Windows platform
    MySQL v.5.1
    phpMyAdmin - 2.11.2.2
    Apache Server v.2.0

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 id
    By jcb23 in forum Help
    Replies: 4
    Last Post: 2009-03-23, 02:44 PM
  3. Auto Increment Integer Field
    By Spy123 in forum Developer Help
    Replies: 0
    Last Post: 2007-01-24, 10:02 AM
  4. How to make id auto increment
    By agvg in forum Developer Help
    Replies: 2
    Last Post: 2006-11-18, 07:37 AM
  5. Replies: 0
    Last Post: 2006-03-06, 07:41 AM

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
  •