In Output screen unable to see any script

neelamallik
Giga Contributor

var gr = new GlideRecord('incident');
gr.addEncodedQuery(
'sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()'
);
gr.query();

 

Can anyone please tell me what is wrong with this script

8 REPLIES 8

vaishali231
Tera Guru

@neelamallik 

Correct Script :

var gr = new GlideRecord('incident');
gr.addEncodedQuery(
    'sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()'
);
gr.query();
gs.info(gr.getRowCount());

vaishali231_0-1768659301962.png

 

*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.

Regards
Vaishali Singh

AzeemullahA
Tera Contributor

Hi @neelamallik,

In the output section, only the output is shown, not the code.
If the code is used in the correct way, it will work properly.
Copy and paste the sample code I have shared; it will make your work easier.

 

Paste this code in your Background Script!

 

var gr = new GlideRecord('incident');
gr.addEncodedQuery("sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()");
gr.query();

while(gr.next()){
    gs.print(gr.number); //here you can print anything from your incident.
}
 
 “After that, the output will appear like this.”
AzeemullahA_2-1768659820974.png

If you feel that you received help because of me, please mark it as helpful.

Sarthak Kashyap
Mega Sage

Hi @neelamallik ,

 

Please try below script, you need to print some output in your script

 

var gr = new GlideRecord('incident');
gr.addEncodedQuery(
'sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()'
);
gr.query();
if(gr.next()){
	gs.print("Number = " + gr.getValue('number'));
}
 

Result 

SarthakKashyap_0-1768665869293.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak

 

yashkamde
Tera Guru

Hello @neelamallik ,
Use this : 

'sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()'

This I copied from the filtered condition copy query and noticed some query mistake in this and your's..

If my response helped mark as helpful and accept the solution..