Execute schedule report from script

pramodkumar
Tera Expert

Hi All,

I'm using below script to trigger a scheduled report from script. Is there a way we can avoid calling packages directly? 

var gr=new GlideRecord('sysauto_report');

gr.get('name', 'Report Name'); // name of my schedule report.

if (typeof SncTriggerSynchronizer != 'undefined')

SncTriggerSynchronizer.executeNow(gr);

else

Packages.com.snc.automation.TriggerSynchronizer.executeNow(gr);

 

 

Thanks!

4 REPLIES 4

Matthew_13
Kilo Sage

Yes Friend— you can!

You should avoid calling Packages.* directly.

The clean approach is to rely only on SncTriggerSynchronizer. If it’s not available in your instance, dont fall back to the Java package call; that’s internal and not upgrade-safe.

Simplest safe pattern:

var gr = new GlideRecord('sysauto_report');
gr.get('name', 'Report Name');

if (typeof SncTriggerSynchronizer !== 'undefined') {
  SncTriggerSynchronizer.executeNow(gr);
} else {
  gs.error('SncTriggerSynchronizer not available – report not triggered');
}

If you need more control or compatibility -  Fire an event and trigger the report from a Script Action instead. That keeps all the platform specific logic in one place.

Bottom line:
SncTriggerSynchronizer = OK
Packages.* = Avoid if you care about upgrades

 

@pramodkumar - Please mark as Accepted Solution and Thumbs Up if you find Helpful!!

Ajay_Chavan
Kilo Sage

@pramodkumar  -

Your script is already using the recommended approach. The Packages call is the fallback when SncTriggerSynchronizer is unavailable.


Refer :
Execute Scheduled Jobs: https://community.servicenow.com/community?id=community_question&sys_id=f5318be5db98dbc01dcaf3231f96...


Scoped App Workaround: https://www.servicenow.com/community/developer-forum/schedule-script-using-script/m-p/2760287

 

 

 

Glad I could help! If this solved your issue, please mark it as Helpful and Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****

Ankur Bawiskar
Tera Patron

@pramodkumar 

try this without package call

var gr = new GlideRecord('sysauto_report');

if (gr.get('name', 'Report Name')) { // name of my schedule report.
    gs.executeNow(gr);
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@pramodkumar 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader