- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:13 AM
Hi,
I'm trying to setup a scheduled job to find Problems which meet a criteria and trigger an event which will fire a notification. I've tried to use an Encoded Query to apply the filter but I can't get it to work. Am I missing something here because as far as I can tell this should work. It's the encoded query that isn't working but this is taken directly from list view.
Any help appreciated
My code is
// This scheduled job runs every morning and looks at all Problems which are associated with an MI
// Where these exist it checks that they havent had a post mortem and whether it has been 7 days since a reminder was sent
// where this is the case it triggers the event rb.problem.mipm and updates the reminder date to 7 days in the future
// Note that u_post_mortem_reminder_sent is not the sent day but actually the date the next reminder is due.
var gr = new GlideRecord('Problem');
gr.addEncodedQuery("u_mi_referenceISNOTEMPTY^u_mi_post_mortem_submitted=false^u_mi_post_mortem_reminder_sentONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)");
gr.query();
gs.log("PL - Rows found" + gr.getRowCount());
while (gr.next()) {
gs.eventQueue("rb.problem.mipm",gr);
}
I'm getting the following error:
java.lang.NullPointerException
Caused by error in <refname> at line 6
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:24 AM
Hi Peter,
Basically, seems fine to me.
Just a thought:
1. change Problem to problem
2. try: var encQuery = '<your query here>';
gr.addEncodedQuery(encQuery);
3. if it does not work, create a "after" br on the problem table with the code and trigger it from the scheduled job. Just for testing.
harel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:21 AM
replace this
gs.eventQueue("rb.problem.mipm", gr, gs.getUserID(), gs.getUserName());
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:24 AM
Hi Peter,
Basically, seems fine to me.
Just a thought:
1. change Problem to problem
2. try: var encQuery = '<your query here>';
gr.addEncodedQuery(encQuery);
3. if it does not work, create a "after" br on the problem table with the code and trigger it from the scheduled job. Just for testing.
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:27 AM
Thanks - not sure whether it was the case on problem or separating the query but it's creating the log now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:31 AM
It's case sensitive, so my guess, the first one.
harel