- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 10:39 AM
Experts,
I have a scoped application OnDemand syauto_script creating a custom event. This scheduled event (gs.eventScheduled : code below) is basically creating a script which kicks a script action
gs.eventQueueScheduled('x_abc_scope.trigger_next_sch', scheduleGr, "trigger_next_job", scheduleGr.getUniqueValue(), gdt);
The script action contains a script which needs to trigger a schedule script execution (sysauto_Script).
When the scheduled event runs, I am not able to see the script action 'script' not getting executed. Below is the script within the script action. The script action is created on the scoped app.
// here parm2 is coming from the event
try {
gs.info('Trigger next schedule job starting <--');
var schedGr = new GlideRecord("sysauto_script");
if (schedGr.get(event.parm2)) {
gs.executeNow(schedGr);
gs.info("Triggered for sysauto_script");
}
}
catch (ex) {
throw new Error('Unable to find sysauto_script with sys_id passed from event '+ex.message);
}
sysevent created
Thx
ram.
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 04:37 PM
Closing the thread.
The issue was with my event condition check. As I said, the issue was something silly and now its all working fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 12:41 PM
I may be missing something silly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 10:54 AM
Did you make sure the Script Action is active? The default value for Active on Script Actions is false
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 11:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 11:57 AM
I have a curiosity: why do you want to trigger a scheduled script from a script action? The way I see it, whatever is in the Scheduled Script that the Script Action should trigger, belongs into a Script Include and that is what the Script Action should trigger instead.
Also, to better understand what's going on, could you show how is scheduleGr created and queried - in the Scheduled Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 12:29 PM
couple of reasons,
- the second scheduled script is an OnDemand one and I am unable to calculate the precise time at which that needs to be run.
- second script is dependent on the completion of a first scheduled job which processes 1M+ records.
- I am doing some estimate on the processing time of the records based on the count + buffer time and creates a scheduled event ( which invokes the script action & thereby triggering sched job )
Hope that makes sense.
SchedGr is created based on the first schedule and a function inside it. ( pass the count and the next script name)
var gdt = new GlideDateTime();
var totalTimeMs = count * 2000 + 120000; // test values
gdt.add(totalTimeMs);
var schedGr = new GlideRecord('sysauto_script');
schedGr.addQuery('name', autoScriptName);
schedGr.query();
if (schedGr.next()){
gs.eventQueueScheduled('x_abc_scope.trigger_nxt_sch', schedGr, "trigger_next_job", schedGr.getUniqueValue(), gdt);
return 'success';
}
else
return 'failed';