Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

list of incident related scripting

Anjali yadav1
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