We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

list of incident related scripting

AnjaliY27945328
Tera Contributor

hello everyone, can anyone write the script for getting the list of incidents updated today

1 REPLY 1

JP - Kyndryl
Kilo Sage
var GetUpdatedTodayIncidents = Class.create();
GetUpdatedTodayIncidents.prototype = {
    initialize: function() {
    },
 
    getIncidentsUpdatedToday: function() {
        var incidents = [];
        var gr = new GlideRecord('incident');
        var today = new GlideDateTime();
        today.setDisplayValue(gs.nowDateTime());
 
        gr.addEncodedQuery('sys_updated_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
        gr.query();
 
        while (gr.next()) {
            var incident = {
                number: gr.getValue('number'),
                short_description: gr.getValue('short_description'),
                sys_updated_on: gr.getValue('sys_updated_on')
            };
            incidents.push(incident);
        }
 
        return incidents;
    },
 
    type: 'GetUpdatedTodayIncidents'
};
 
Regards,
JP