Triggering a script action from an event

Ram117
Kilo Sage

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 

find_real_file.png

 

Thx

ram.

 

1 ACCEPTED SOLUTION

Ram117
Kilo Sage

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.

View solution in original post

14 REPLIES 14

Are you sure there is just one scheduled script with that name (whatever is in autoScriptName)? Is the proper record visible in the sysevent record generated when the schedule command is executed?

Also wouldn't this be better handled by using a Job (sys_trigger)? You only need one scripted job, associated with a specific node - so that no parallel execution happens on multiple nodes. No scheduled scripts, no event, no script action, just a Job (and a Script Include 😉 ).

I passed the sys_id of the auto script, that too didn't work.

How do you propose to initiate the sy_trigger record ?

It is a simple matter of creating a new record in that table. Enter sys_trigger.do into the navigator filter and press enter:

find_real_file.png

Next fill in required information making sure that in Job ID you select RunScriptJob. Select any node in System ID and select Interval in Trigger type. Enter the script to be executed into Script.

Just make sure that upon system upgrades the job is restarted. Also this is not moved using update sets. Perhaps another article -  scheduled job sys_trigger here on community will also help.

Thank you for the reply.

May be I did not state it correctly in my post. I had all the custom event created and its schedule created which would pick these events. Even without a custom event, it would picked by the default event processors.

The issue was with my condition check on the script action.

Thank you for taking time to reply. Appreciate the responses.

Ram117
Kilo Sage

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.