- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2015 12:13 PM
I am modifying Chuck Tomasi's Loaner Request Module and have run into a problem. The e-mail notifications included in the update set do not appear to be triggering. I also confirmed that the below simple script returns "undefined" when fired in a script include, but not when fired from the Background Script module. This would likely be the source of the problem as Chuck's code uses a script include to query for the loaner requests that need an e-mail triggered.
var gr = new GlideRecord('loaner_request');
gr.query();
while(gr.next()) {
gs.log(gr.number);
}
It works fine if I run it from a script include on the incident or even loaner_task tables. I noticed by debugging the script that gr.query() does a role check for "loaner_admin" role that is not performed when querying other tables. I tried disabling all of the non-field-specific ACLs on the loaner_request table just to test this theory, but was still receiving the same results. I'm sure it is something obvious that I am overlooking. Any suggestions would be helpful. Thanks!
Edit: I have determined that the only time the query does not work is when I specifically access it from a scheduled job and query the loaner_request table. If I use the same scheduled job to query the incident table, it does not fail. If I use the background script to run the script include, it does not fail. Curiouser and curiouser.
Message was edited by: Matthew Dumont
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 09:14 AM
Hi Matt,
Try adding the "Run as" field the the scheduled job and using an account that has the loaner_admin role.
Regards,
Trey Carroll
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2015 02:00 PM
Do not use variables named "gr" in Background Scripts, they can produce unexpected results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 06:53 AM
Thank you for the note. Unfortunately, that was just an example. I've used several different values for the variable throughout testing. The background script, however, has not shown any issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 09:14 AM
Hi Matt,
Try adding the "Run as" field the the scheduled job and using an account that has the loaner_admin role.
Regards,
Trey Carroll
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2015 09:17 AM
Trey,
Thanks so much for your response! The "Run As" field was blank on each scheduled job. I populated the field with my name and ran the scheduled job, which worked. Then, oddly, it continued to function correctly after I totally blanked out the "Run As" field again. I will be investigating what might have caused this to make sure it won't cause us further issues in the future.
Cheers,
Matt Dumont