Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Background Scripts

Akshat8
Tera Contributor

Hello Everyone , I want to write a background script to print last 5 incidents created yesterday and also we have to implement it only using background script. Anyone has any solution? Thanks in advance.

2 ACCEPTED SOLUTIONS

Not applicable

Hello @Akshat8  ,

Pls try this script:

 

bgss.png

 

@Akshat8  , Please mark my answer as "Accept as Solution" and "Helpful." If it works for you.

 

Thank you.

View solution in original post

Uday_Kumar
Giga Guru

Hi @Akshat8  How are you ?

I am pasting my code please have a look.

var gr=new GlideRecord('incident');
gr.addEncodedQuery('sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()');
gr.orderByDesc('sys_created_on');
gr.setLimit(5);
gr.query();
while(gr.next())
{
    gs.print("The Incident Number is "+gr.number);
}

If my solution helps you please mark my Solution Accepted and Helpful.

Thanks and regards

Uday Kumar Valapudasu

View solution in original post

6 REPLIES 6

Uday_Kumar
Giga Guru

Hi @Akshat8  How are you ?

I am pasting my code please have a look.

var gr=new GlideRecord('incident');
gr.addEncodedQuery('sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()');
gr.orderByDesc('sys_created_on');
gr.setLimit(5);
gr.query();
while(gr.next())
{
    gs.print("The Incident Number is "+gr.number);
}

If my solution helps you please mark my Solution Accepted and Helpful.

Thanks and regards

Uday Kumar Valapudasu

Thank you so much for the help.