How to automatically assign account codes to customers?
  • Andrew
    How to automatically assign account codes to customers?

    by Andrew » Fri Aug 04, 2006 3:51 pm

    My company's customers are generally COD accounts or credit card accounts, and are members of a wine club. I'd like the system to automatically assign a numeric account code to each new customer we create automatically. If our customer is an account customer, I would still like to let our users enter an alphabetical account code. Is this possible? If so, any clues on how to go about it?
  • COBS Tech Support
    Posts:683
    Joined:Fri Sep 09, 2005 8:23 am

    by COBS Tech Support » Fri Aug 04, 2006 3:57 pm

    Place this script inside the Customer Screen Script section of the Screen Builder. If the account code is left blank, a numeric account code will be assigned to the account automatically. This will be based on the next available numeric customer account.

    If operators enter an account code, this will be used instead.

    * Mode = 3 'save record' event
    If Mode = 3
    * SCRMode() = 1 = add a new record
    If SCRMode() == 1 .And. IsEmpty(SCRRead("CUSCODE"))
    Declare nRecNo Type Number
    Declare nNextNo Type Number
    nRecNo := Custrec->(RECNO())

    * Find closest match to customer account 99999999
    Custrec->(Find("99999999",, TRUE))
    Custrec->(Skip(-1))
    nNextNo := VAL(Custrec->Cuscode) + 1
    Custrec->(Goto(nRecNo))
    SCRWrite("CUSCODE", NTrim(nNextNo))
    Endif
    Endif

Who is online

Users browsing this forum: No registered users and 3 guests