Increment an field

Dear all,

I have to create a field that increments the number 1 2… and so on .Have written the code in he table insert trigger . i.e

“Version No” : = “Version No” + 1;

It is not working . the value remains only 1 . ERROR: SalesHeaderArchive 1 already exists.

With regards,


Think about it step by step. The OnInsert trigger is called. “Version No.” refers to the field in the record that you are trying to insert. Assuming you have not set it before it will always be zero.

If you want to find the last version number used you will need to FIND that record in the database. Then assign the “Version No.” of the record being inserted to the “Version No.” of the record you found + 1.

On which trigger you increments the Version No ?

For what purpose you incremet the Version Number ?

  1. If you increment it to display the “version No” on report then write the inrement code at “OnAfterGetRecord” trigger"

2.if you wnt to increment the “Version number” at table level,then write increment code at “OnInsert” trigger. Get the higest Version number and increment it.