在字段上设置默认值? [英] Setting default value on a field?
问题描述
我要向现有的表中添加一个新字段(不是核心字段,而是以前由内部开发人员创建的字段),并且我试图设置默认值
I'm adding a new field to an existing Table (not a "core" one, but one that was created by an inhouse dev previously) and I'm trying to set a default value for it.
我创建了一个类型为 Int 的字段,但是默认情况下,它已经存在的记录全为0。
I created a field of type Int, but now by default it's all 0's for the records that are already there.
是否可以为所有现有记录和要插入的记录定义该字段的默认值?
Is there any way to define a default value for that field, for all the existing records and to be inserted records ?
最终,我想要实现的是我想要一个可配置的字段(ShowOnReport),以便某些记录不会显示在 Web报表中。现在,我希望将此字段设置为默认值到1到所有现有记录,然后根据业务需要将它们切换为0。
Ultimately, what I'm trying to achieve is that I want a configurable field (ShowOnReport) so certain records won't show up in a Web Report. Right now, I want this field to default to 1 to all existing records, and later, switch them to 0 depending on business needs.
也许我的术语理解错了,但是Google和Bing却不愿我对此...:(
Maybe I've got the termininology wrong, but Google and Bing are mute to me regarding this... :(
谢谢!
推荐答案
根据您的描述,我认为您的领域应该是典型的e NoYesId
,它类似于布尔值,但默认情况下显示为复选框。
From your description I think your field should be of type NoYesId
which is similar to a boolean but is rendered as a check box per default.
获取默认值您应该覆盖表方法 initValue
并将字段设置为 NoYes :: Yes
-这样可确保所有新记录。对于现有记录,您必须编写一个简单的AOT作业,该作业通过 update_recordset
将 NoYes :: Yes
设置为您的字段。
For a default value you should overwrite the table method initValue
and set your field to NoYes::Yes
- this ensures the default value for all new records. For your existing records you have to write a simple AOT Job which sets NoYes::Yes
to your field via update_recordset
.
这篇关于在字段上设置默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!