- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 03:47 AM
Looking to write a scheduled job conditional script that would query on the assignment group and the short description of the sctask and if it returns true do not run else run the job
Any ideas on what could be wrong with the following script:
var gr = new GlideRecord('task');
gr.addQuery('assignment_group', 'Home Office Building Operations');
gr.addQuery('short_description', 'Monthly Sprinkler System Maintenance - Home Office');
gr.addActiveQuery();
gr.query();
if (gr.next()) {
return true;
}
else {
return false;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 04:30 AM
this should work,
answer= true;
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery('assignment_group=SYS_ID of Home Office Building Operations^short_descriptionLIKEMonthly Sprinkler System Maintenance - Home Office');
gr.addActiveQuery();
gr.query();
if (gr.next()) {
answer=false;
}
else {
answer= true;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 04:30 AM
this should work,
answer= true;
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery('assignment_group=SYS_ID of Home Office Building Operations^short_descriptionLIKEMonthly Sprinkler System Maintenance - Home Office');
gr.addActiveQuery();
gr.query();
if (gr.next()) {
answer=false;
}
else {
answer= true;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 04:53 AM
This scheduled job will not run if there are active SC_tasks assigned to home office and short description you mentioned.