Update exisitng records

VSN
Tera Expert

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

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