Want the customer Number.

Mar 10, 2006 5 Replies

I have added a hook when adding new customers. I want to get the customer number when I save the customer. My code is as follows:-



Public Function Process(mySession As QSRules.SessionClass) As Boolean


Dim StrSql As String Dim ConConnection As New ADODB.Connection Dim rstRecordSet As New ADODB.Recordset Dim QsCustomer1 As QSRules.Customer 'Need to populate referralcode and age group


MsgBox mySession.Transaction.Customer.AccountNumber, vbInformation, "test"



Process = True End Function


When I run the function the customer.accountnumber is blank and customer.loaded returns false. Why is this the case?



Cheers, Sos


This is because the customer's account number is not created automatically. Unlike when you're creating a customer using the standard RMS GUI where the software assigns a consequititve number, the database or QSRules don't do it.

Write your own procedure, like GetMacAccountNumber() to assign the number automaticaly.

"Sospeter" wrote:

Hi,

But I want that number so that I can do some updates to that Customer. Not be> This is because the customer's account number is not created automatically.

Hmm. Good question. The short answer - any way you want :-). One way is to generate random unique account numbers sor to like UID but shorter. The other way is, if your accounts are numeric, get the last max account number using something like the SQL statement: SELECT MAX(cast(Customer.AccountNumber as int(8)))+1 Or, if you use VB, get a recordset of all customers and cycle through the acount to find the max number.

Etc.

PS. I haven't actually tested the SQL statement above so use with cauti> How would I do that.

Sospeter,

First, make sure that the parameter of the Save Customer hook is 5.

I think the value is just mySession if the parameter is 5. If you use the full QSRules I believe it doesn't work at all.

Good luck, Matt

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required