Skip to content

Commit 9742096

Browse files
authored
Create script.js
1 parent 1106276 commit 9742096

File tree

1 file changed

+18
-0
lines changed
  • Server-Side Components/Scheduled Jobs/Trigger Email and pass week parameter

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//Trigger notification and pass the week number in the parameter
2+
3+
var grSSIPIR = new GlideRecord(<table_name>);
4+
//trigger notification if it statisfy query condition
5+
grSSIPIR.addEncodedQuery(<query>);
6+
grSSIPIR.query();
7+
while (grSSIPIR.next()) {
8+
9+
var startDate = new GlideDateTime(grSSIPIR.sys_created_on);
10+
var endDate = new GlideDateTime();
11+
12+
var millisecondsBetween = endDate.getNumericValue() - startDate.getNumericValue();
13+
var weeks = millisecondsBetween / (1000 * 60 * 60 * 24 * 7);
14+
15+
var weeks_roundoff = Math.floor(weeks);
16+
17+
gs.eventQueue("<event_name>", grSSIPIR, weeks_roundoff, "");
18+
}

0 commit comments

Comments
 (0)