8
Views
7
Comments
Solved
Default value of Entity attribute Id ignores the default value
Question
Platform Version
11.10.0.25600

Hi All,

I am trying to set the default value of the entity attribute to some static value, 1000000, and still keep it AutoNumber. My understanding of this is that the Id will start from 1000000 and since it is set to AutoNumber True it will auto calculate the records ids as 1000001, 1000002, 1000003 etc. If I do not provide the default value in this case then the generated Ids would be 1, 2, 3 etc. However, I am getting the Ids generated as 1, 2, 3 in the first case as well. Here is the snapshot of what I am trying to do:


Platform: OS 11

Application: Reactive Web

Tried on Personal Environment.


Is my understanding incorrect? Can I achieve this without implementing the sequence logic on my own?

Thanks,

Akshay

mvp_badge
MVP
Rank: #2
Solution

The Default Value for an Attribute is the value that the Attribute has when the Entity Record or Structure is first intialized. So if you, say, create a Local Variable of a certain Structure, then the initial values of the Attributes of that Structure will have the Default Value. You should never set it for an auto-increment Id, because that will have the same effect as assigning that value in the code. Which means it's ignored on a Create, but used for CreateOrUpdate or Update.

mvp_badge
MVP
Rank: #2

Hi Akshay,

Your understanding is unfortunately not correct. You cannot start an auto number from a certain value like that. If you really must, you need access to the database and issue a database-specific command for the physical table (e.g. with DBCC CHECKIDENT on MSSQL).

However, this begs the question: why on earth do you want to control where the auto-number starts? The whole idea of such a number is that you don't care what it is, as long as it's unique.

Rank: #448

Hi Akshay,

I am not sure if this can be accomplished through service studio. However, it might be the case that if default value can set from backend i.e. SQL Server or Oracle database this would be possible. I would recommend here is that set autonumber to No and you can write logic to insert the unique entity identifier with your default value following next sequences.

Thanks & Regards,

Sachin