- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 07:09 AM
I want to create a new field (integer) with a value"0" on Incident table. I want this value to be applied on new as well as existing records.
Will the "Default Value" work? if not please suggest any other option.
Thank you,
Navdeep
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 07:34 AM
And they weren't updated:
Yes, we did it differently.
I went through the dictionary
1. went to System Definition -> Dictionary. Clicked on new
2. Choose the incident table, Integer type, and added 0 as default value:
3. Clicked on Submit
4. Run the script to confirm:
Telmo

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 07:14 AM
Default value will only populate new records. If you want to update the existing records, you need to update them manually. Something like this will work without triggering business rules or updating other fields.
var inc = new GlideRecord('incident');
inc.query();
while (inc.next()) {
inc.setWorkflow(false);
inc.autoSysFields(false);
inc.u_count_field = 0; // Change to YOUR field name
inc.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 07:19 AM
I just tried Chuck, And it worked for me. The default value is populated in the existing records as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 07:16 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2016 07:21 AM
Hi Telmo,
Be careful... The list will display a 0, but that's not really stored in the database until the record is created/updated.
I just ran this simple little script to verify and got the following output on number and u_count, where u_count has a default value of 0.
var inc = new GlideRecord('incident');
inc.query();
while (inc.next()) {
gs.print(inc.getValue('number') + ' - ' + inc.getValue('u_count'));
}