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