Hi all,
I try to set a default value for a numeric field. I can't figure out why it does not work.
I simply set default value this way : schema.model.fields.MyNumericField to {defaultValue : 9, type:"number"}.
All I get when I create a record is 0.
I join screenshot of entire schem model.
Thanks in advance for any help,
André.
4 Answers, 1 is accepted
After hours of research, I fixed it by putting the same default values in database schema. Is it the way it is supposed to work ?
What if I need a different value than the default database value ? (Progress Database)
André.
In general, the defaultValue parameter indicates the default value that will be used when a new model is created and depends on the type of the field. However, to answer your first question, I will need additional information. Therefore, could you elaborate a bit more on the database schema part and the exact scenario where the defaultValue is not working? It would be most helpful if you could provide an isolated example where the issue can be reproduced. I would suggest to open a separate support ticket where we can continue our communication.
Concerning the different default value query - the parameter could be set as a function. Refer to the following HowTo example, where a similar scenario is demonstrated:
Regards,
Dimitar
Progress Telerik
Hi Dimitar,
I wanted to set default values to numeric fields. That is when I create a record, I want the input fields to be set to the default value I supplied in model. In the Progress database, these integer fields had "0" as initlial value.
In my model, I set default value to -1. It did not work. I also tried to set default value to 9 in order to check wether negative value was the problem but it wasn't. Finally, I set initial value to -1 in the Progress database. After that, it works.
I can't figure out how to provide isolated example as database seems to be concerned.
Regards,
André.
I would suggest to open a separate support thread, where you could provide additional details regarding the issue and the exact scenario. There, you could also send us an isolated solution that reproduces the issue. You should be able to use dummy data to construct the server response without the need to attach a specific database.
Regards,
Dimitar
Progress Telerik