Execute scheduled email report on event trigger

Rajanmehta
Mega Guru

Hello,

I have a requirement to run scheduled email report (on Demand) to run on an event trigger. 

I don't see any option to execute the report on event trigger. Is there any work around I can use?

Please advise.

Thanks.

find_real_file.png

 

 

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

Hi Rajan,

You cannot directly trigger scheduled jobs based on the event. However, you can trigger Script Action based on an event and inside Script action you can use the below script to trigger an on-demand scheduled job. 

var schReportGr = new GlideRecord('sysauto_report');
schReportGr.addQuery('sys_id','<SYS ID>'); //replace <SYS ID> with actual sys_id of your schedule report
schReportGr.query();

if(schReportGr.next()){
   SncTriggerSynchronizer.executeNow(schReportGr);
}

Note - Above script will work in the Global scrope.

Hope that helps!

Regards,

Muhammad

Regards,
Muhammad

View solution in original post

4 REPLIES 4

MrMuhammad
Giga Sage

Hi Rajan,

You cannot directly trigger scheduled jobs based on the event. However, you can trigger Script Action based on an event and inside Script action you can use the below script to trigger an on-demand scheduled job. 

var schReportGr = new GlideRecord('sysauto_report');
schReportGr.addQuery('sys_id','<SYS ID>'); //replace <SYS ID> with actual sys_id of your schedule report
schReportGr.query();

if(schReportGr.next()){
   SncTriggerSynchronizer.executeNow(schReportGr);
}

Note - Above script will work in the Global scrope.

Hope that helps!

Regards,

Muhammad

Regards,
Muhammad

Thanks Muhammad.

That was really helpful. I am able to trigger the report directly from the Business Rule. I was first thinking of generating event via Business Rule, but no need to take that path.

Thanks again.

 

Hey Muhammad,

 

I have a similar requirement, but your code isn't working in my case. How would you do to adapt it to work in a scoped application ? I'm received that error:

Uncaught TypeError: GlideRecord is not a constructor

BinuB
Tera Contributor

Thank you so much. This was really helpful