- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2017 12:08 PM
Forgive me I am learning
I have submitted a scheduled job, when I click 'execute now' the job does not run. I cannot see an entry in event logs.
If I copy the script from the scheduled job and run it in background scripts - it inserts the rows in event logs and (the rest of the processing) works fine.
var res = new GlideRecord('x_hotel_reservation');
res.addQuery('departure', gs.now());
res.addNotNullQuery('room');
res.query();
while(res.next()){
gs.eventQueue('x_hotel.room.reservation_end', res.room.getRefRecord());
}
I can only assume something is wrong with the scheduled job I am trying to run.
any help directing me to a solution would be welcomed.
Many thanks for your time.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2017 01:18 PM
Hi,
Since this is a scoped application, it seems your scheduled job is unable to create new records in the sysevent table but when you run it from a background script, the scope is global and you are getting access to add records in the sysevent table. I suggest you try configuring table application access by allowing other application scopes to create records in sysevent table. Please check and let me know
Application Access Settings - ServiceNow Wiki
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 01:05 AM
Alikutty
Success!
I had to change the suggestion from Rajshekhar since looking at the logs I found:
com.glide.script.fencing.MethodNotAllowedException: Function log is not allowed in scope x_hotel. Use gs.debug() or gs.info() instead
after the table permission changes you suggested, I went back to gs.now() but as he stated this didn't work but proved a point in my head.
I changed his script to use gs.info instead and all worked as it should. I need to reverse out the changes you suggested (to see whether the permissions were connected - but I assume they were needed).
I'm assuming that the combination of both changes (using gs.now() and table permissions - helped me and I thank you both for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 01:02 AM
Rajshekhar
Success!
looking at the logs I found:
com.glide.script.fencing.MethodNotAllowedException: Function log is not allowed in scope x_hotel. Use gs.debug() or gs.info() instead
after the table permission changes, I went back to gs.now() but as you stated this didn't work but proved a point in my head.
I changed your script to use gs.info instead and all worked as it should. I need to reverse out the changes suggested by Alikutty (to see whether the permissions were connected - but I assume they were needed).
I'm assuming that the combination of both changes helped me and I thank you both for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 01:09 AM
Hi Laurence,
I am glad that I could help. Thanks for your confirmation.
Regards,
Rajshekhar Paul
