We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How To write Query for incidents opened on today

jenny32
Tera Guru

Hi,

I am trying to display by using

var inc = new GlideRecord('incident');

  inc.addQuery('opened_at', today);

      inc.query();

But, am not getting output for this.

If Any one aware of this help me.

Regards,

jennifer

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee

Hi Jennifer,



Here you go.


var inc = new GlideRecord('incident');


inc.addQuery('active=true^opened_atONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)');


inc.query();


while(inc.next())


  {


  gs.addInfoMessage(inc.getRowCount());


}


View solution in original post

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee

Hi Jennifer,



Here you go.


var inc = new GlideRecord('incident');


inc.addQuery('active=true^opened_atONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)');


inc.query();


while(inc.next())


  {


  gs.addInfoMessage(inc.getRowCount());


}


Hii Pradeep,



Thanq, Now the Code is working.



Regards,


jennifer.


Perfect