Jump to:

23491 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » create sequental client number?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 462 Views
  • voodoochile
    Avatar
    Community Member
    52 Posts

    create sequental client number? Link to this post

    Hi all
    Currently i'm working on a project that has a client dataobject i have this setup and can add clients from both the CMS and also a front end form. as there is a current client list going in that has already established client numbering system, i would like new clients to have a number that follows on from the last number, this number needs to auto generate when a new client is added from either the CMS or the front end form.

    so far i know this is done using onbeforewrite, but i have no idea of what to put or where to put it.
    hope someone can help or atleast point me in the right direction thanks

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: create sequental client number? Link to this post

    I'm guessing the "ID" is insufficient?

  • voodoochile
    Avatar
    Community Member
    52 Posts

    Re: create sequental client number? Link to this post

    Hi Swaiba

    The id maybe ok, i had considered using this and appending a group of numbers before, this would mean renumbering the entire client base that exists.
    however as the project is aimed at consolidating several business functions currently residing in a series of excel spreadsheets and various other documents into a single application to be used company wide, this maybe a plausable solution as everything else is going to work around the client number.
    the main reason for not wanting to use the id is more to learn an alternative method to solve this problem as it will no doubt come up later in the project when i start intergrating their mapping software and other systems their may be a requirement to have several fields that do this in a single table.

  • voodoochile
    Avatar
    Community Member
    52 Posts

    Re: create sequental client number? Link to this post

    Hi

    i have spoken to my client and they wish to keep thier current numbering system in place this makes Using the ID not possible

    so if anyone could help please it would be appericated.

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: create sequental client number? Link to this post

    $iNewCustomerNumber = intval(DB::query('SELECT MAX(CustomerNumber) FROM CustomerTable")->value())+1;

    462 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.