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
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.
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.
Thank you Kilian for the response. The need originates from third party I am integrating with requiring values starting from specific point. Although I can create another attribute to store calculated as required, I was curious if the Default Value attribute serves me this readily. With my understanding incorrect, could you please help me understand the purpose of the Default Value attribute? The service studio hint says - "Initial value of this element. If undefined, the default value of the data type is used."
Again Thank you Kilian, I think I am aligned now with this.
Glad I could be of help. Happy coding!
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
Thank you Sachin.