Scheduled Job not running even on Execute Now

rpatnaik
Kilo Contributor

Hi All,

Need a help in running the Scheduled job.The scheduled job is convert a risk into an issue after 10 days of the due date in Risk Form.The Risk state has to be 'Convert Issue' once the issue is created .But the Scheduled job is not running on the Scheduled time or on clicking  the 'Execute Now'.But when i run it from the background Script i get the expected outcome.

Please help me to run the script.

Script is as below:

var ps = 10;
var pn = parseInt(ps);
var gt=new GlideDateTime();
var query ='issueISEMPTY';


if (pn >= 0) {

var grrisk= new GlideRecord('risk');
grrisk.addEncodedQuery(query);
grrisk.addQuery('due_date', '<', gs.daysAgo(pn));
grrisk.addQuery('sys_id','*****************');
grrisk.query();
while(grrisk.next()) {

var grissue = new GlideRecord('issue');
grissue.short_description = grrisk.short_description;
grissue.description = grrisk.description;
grissue.assigned_to = grrisk.assigned_to;
grissue.risk = grrisk.sys_id;
grissue.parent = grrisk.task;
var issueSys = grissue.insert();
grrisk.issue = issueSys;
grrisk.state = 'convert_Issue';
grrisk.update();

}
}

Thanks in advance

Rashmi

 

39 REPLIES 39

Harsh Vardhan
Giga Patron

best way to check add logs in your script validate if its working or not. 

use gs.log() to check the log details.

 

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Your script is valid you are mentioning. So how does the scheduled job look like?

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

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Harsh Vardhan
Giga Patron

adding logs and let me know the log details. 

 

 

var ps = 10;
var pn = parseInt(ps);
var gt=new GlideDateTime();
var query ='issueISEMPTY';


if (pn >= 0) {

var grrisk= new GlideRecord('risk');
grrisk.addEncodedQuery(query);
grrisk.addQuery('due_date', '<', gs.daysAgo(pn));
grrisk.addQuery('sys_id','*****************');
grrisk.query();

gs.log('Row Count is '+ grrisk.getRowCount());
while(grrisk.next()) {

var grissue = new GlideRecord('issue');
grissue.short_description = grrisk.short_description;
grissue.description = grrisk.description;
grissue.assigned_to = grrisk.assigned_to;
grissue.risk = grrisk.sys_id;
grissue.parent = grrisk.task;
var issueSys = grissue.insert();
grrisk.issue = issueSys;
grrisk.state = 'convert_Issue';
grrisk.update();

}
}

Hi Harsh,

 

Thank you for the response.Even though i put a log statement at the first line of the code it doesn't display on the logs.

Or if i create a Test Scheduled Job with just one line of log statement..that also not getting printed on the logs.

gs.log('Test Log');

 

Regards,

Rashmi