history records with GlideRecord within e.g. 2 minutes

js20
Mega Guru

In business rule I want to find history incidents which where 2 minutes opened apart from current incident 

something like

addQuery ('opened_at', <, current.opened_at.timeDiff(2) ) 

 ???

 

thanks.

4 REPLIES 4

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can use this filter

find_real_file.png

 

In the query it will be like

addEncodedQuery('opened_atONCurrent minute@javascript:gs.beginningOfCurrentMinute()@javascript:gs.endOfCurrentMinute()^ORopened_atONLast minute@javascript:gs.beginningOfLastMinute()@javascript:gs.endOfLastMinute()' ) 

 

-Anurag

-Anurag

Mark Roethof
Tera Patron
Tera Patron

Hi there,

You could create such a filter easily using the condition builder on any list. Then simply copy the breadcrumb, and use it in an encoded query:

2019-09-04 Utilizing the breadcrumb on lists to generate your query

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

js20
Mega Guru

those javascript datetime functions is from now (or when they are executed). What I want to do is  to check when the incident is resolved if there was other incident opened at approximately same time +-2minutes so I cannot use function gs.minutesAgo(2) or similar. I need to get incidents which are abs(current.opened_at-gliderecord.opened_at) < 2minutes .

 

So probably I need to do gliderecord.next() to go thru all records.

When they a re executed

-Anurag