Unique userdefined Numeric ID creation

Hi…I have a Company Master form which has a "companyid"field which should accept unique number like 1,2 etc starting with 1.In the view the “companyid” field should show 1,2,3

etc in the documents.What should I do so that store the id

as unique???Pls help…

Subject: Unique userdefined Numeric ID creation

HiIf you would like the numbers to be unique AND sequential this is a really difficult this to accomplish, in a clustered, fail-over environment I would like to say that it is close to impossible.

If we work under the assumptions that

  1. there are not that many persons entering new companies into the database (and they rarely do it at the same time)

  2. If 2 companies get the same number it is not the end of the world and you can go into the document and change the number

You can create a view with all the numbers in the first column and on the companyform you have a computed when composed field with a formula like

@max(@dbcolumn(“”;””;”allNumberView”;1))+1;

This is the easy solution for a small, not-business-critical solution. If this is NOT the case don’t use it. If it is a business critical database that has lots of users I would create a synchronized java agent (an agent that calls a synchronised class) that only runs on one server (in a clustered environment). This class keeps track on the number used and return a number then requested. The problem is then (if) that server goes down, no one will be able to enter new companies into the system.

Subject: Unique userdefined Numeric ID creation

HiIf you would like the numbers to be unique AND sequential this is a really difficult this to accomplish, in a clustered, fail-over environment I would like to say that it is close to impossible.

If we work under the assumptions that

  1. there are not that many persons entering new companies into the database (and they rarely do it at the same time)

  2. If 2 companies get the same number it is not the end of the world and you can go into the document and change the number

You can create a view with all the numbers in the first column and on the companyform you have a computed when composed field with a formula like

@max(@dbcolumn(“”;””;”allNumberView”;1))+1;

This is the easy solution for a small, not-business-critical solution. If this is NOT the case don’t use it. If it is a business critical database that has lots of users I would create a synchronized java agent (an agent that calls a synchronised class) that only runs on one server (in a clustered environment). This class keeps track on the number used and return a number then requested. The problem is then (if) that server goes down, no one will be able to enter new companies into the system.