Description of Issue:
There could be times when the registration code is not populated on the AR_Customer records.
If the code is not populated and the customer information is saved it will cause the error below.
Resolution:
If it is just one or a few you can populate the registration code by using the refresh button in the customer information screen. Then you can save the customer record.
If the code is missing from many customers, the script below can be executed to check and then populate the Registration code for any customer that does not have one already.
-- Populate registration code when not already there. declare @CustomerId int, @code varchar(20) declare cCustomer cursor forward_only static read_only for select Customer_Id from AR_Customer where isnull(Registration_Code, '') = '' order by Customer_Id open cCustomer fetch next from cCustomer into @CustomerId while @@fetch_status = 0 begin GetCode: execute dbo.Generate_Random_Code 6, @code output if exists (select Customer_Id from AR_Customer where Registration_Code = @code) goto GetCode update AR_Customer set Registration_Code = @code where Customer_Id = @CustomerId fetch next from cCustomer into @CustomerId end close cCustomer deallocate cCustomer go