Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread OnBeforePost
Tue, Apr 10 2007 4:35 PMPermanent Link

"Petrus van Breda"
Hi

I have an application that will generate Reference Number. When the user
Save the Record I will add teh reference number in OnBeforePost. The problem
is that if a user get an error on his/her input ir a required field the
number will not increase, but when they abandon the record the number are
lost. How can I check for any application errors and none is received only
then add the reference number.

Thanks

Petrus

Tue, Apr 10 2007 5:25 PMPermanent Link

Sean McCall
Petrus,

If you are using a table to generate the reference number, do everything
within a transaction. If it fails, the reference number generation will
be rolled back when you call Database.Rollback. If you use a
non-database means to get your reference number, use a try-except block
around the transaction or post and reset the number before you roll it back.

Alternatively, you could also check the required fields yourself before
you generate the reference number to make sure that all required fields
are entered. Downside is that this would still skip a reference number
if some other error came up.

Sean

Petrus van Breda wrote:
> Hi
>
> I have an application that will generate Reference Number. When the user
> Save the Record I will add teh reference number in OnBeforePost. The problem
> is that if a user get an error on his/her input ir a required field the
> number will not increase, but when they abandon the record the number are
> lost. How can I check for any application errors and none is received only
> then add the reference number.
>
> Thanks
>
> Petrus
>
>
Image