SncTriggerSynchronizer.executeNow() is not working on background script

jordimsant
Mega Sage

I am trying to launch scheduled job from Background Script and it does not work. The script I am using is

var gr_micro = new GlideRecord('sysauto');
gr_micro.get('93bbb322871e521024530fa90cbb3524');
SncTriggerSynchronizer.executeNow(gr_micro);

The error that I am getting is shown in the following image:

jordimsant_0-1736318480038.png

Can anybody help me? I have checked that the sys_id is correct, so the record is correctly found.

 

1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage

Hi @jordimsant 

Ensure you are logged in as a user with the admin role and that the instance allows background script execution of such operations.
correct format :-

var gr_micro = new GlideRecord('sysauto');
if (gr_micro.get('93bbb322871e521024530fa90cbb3524')) {

if (gr_micro.active) {
gs.print("Found scheduled job. Executing now...");
SncTriggerSynchronizer.executeNow(gr_micro);
} else {
gs.print("Scheduled job is inactive. Activate it before execution.");
}
} else {
gs.print("Scheduled job not found.");
}

 

View solution in original post

3 REPLIES 3

Ravi Gaurav
Giga Sage

Hi @jordimsant 

Ensure you are logged in as a user with the admin role and that the instance allows background script execution of such operations.
correct format :-

var gr_micro = new GlideRecord('sysauto');
if (gr_micro.get('93bbb322871e521024530fa90cbb3524')) {

if (gr_micro.active) {
gs.print("Found scheduled job. Executing now...");
SncTriggerSynchronizer.executeNow(gr_micro);
} else {
gs.print("Scheduled job is inactive. Activate it before execution.");
}
} else {
gs.print("Scheduled job not found.");
}

 

Thank you for your help! The problem was the "Run as" field, I suppose that the previous user has not the rights to execute the script

Shruti
Giga Sage
var gr_micro = new GlideRecord('sysauto_script');
gr_micro.get('93bbb322871e521024530fa90cbb3524');
SncTriggerSynchronizer.executeNow(gr_micro);