Update exisitng records
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-07-2024 07:05 AM
I have a requirement to create a field in one of the table,, for example, we can consider a new field as Active.
here, my requirement is that if the end date < 2024-03-01, those records need to be marked Active as false.
how can I achieve this functionality?
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-08-2024 01:36 AM
Hi @VSN
Please try this-
var cutoffDate = new GlideDateTime('2024-03-01 00:00:00');
var gr = new GlideRecord('your_table_name'); // Enter your actual table name
gr.addQuery('end_date', '<', cutoffDate);
gr.query();
while (gr.next()) {
gr.active = false;
gr.update();
}
Please mark my answer helpful and correct.
Regards,
Amit