alexpreyer
5th February 2004, 10:18
Hello,

I wrote a session where I use the tcmcs.dll0004.read.default.number-function to get a new auto number.
My problem is to find the best place in code to get a number only once.
At the moment I set the code in before.input section of the auto number field and check the update.status for add set.
But if the user "tabs" through the form and reach the field again he gets a new number. Unfortunately I cannot set the code to the main table io section because the users want the new number when they start to input a new record.

Can someone help me?

Thanks

Alex Preyer

kbartelds
5th February 2004, 10:43
extend the update status check with a check whether the number has already been determined.

Regards,
Klaas

alexpreyer
5th February 2004, 12:05
Thanks Klaas for your answer.
But how can I do this especially when the user enters more than one record?

Thanks

Alex

avpatil
5th February 2004, 14:40
Hi Alex,
Set one more variable. Set the variable in before.program to be fasle. SO if the variable is false then get new number. Once you get the new number set the variable to true. In main in.table.io set the variable to false again. This should resolve the issue.

But then you have to take care of scenario where more than one user is trying to insert the record. Since you haven't updated the first free number, both user might get the same number and one of them will fail. If you have taken care of this scenario then the above code (setting of variable........) should work.

Arvind

kbartelds
5th February 2004, 14:41
Check the field on add.set and value of field. In after.update set field to zero.

Regards,
Klaas

alexpreyer
5th February 2004, 14:56
Ok, I tried the suggestion of Arvind and it seems to work very well.
I get the first free number and update it in the same field section to be sure that everyone get a new number. Its no problem for us if there is a gap in the numbers because someone is canceling his actual record.

Thanks Klaas and Arvind for your help.

Alex