UI Action button to run a Scheduled Job?

Jeanne2
Tera Contributor

I have a Scheduled Job, that is executed via a Scheduled Script execution.  I would like to provide this functionality On Demand to certain personnel, without exposing the script to them.

Is it possible to have a UI Action in a content block on a page (home page or UI page) that can run this script onclick?

I currently have a UI page with a function in the Client script as follows:

function runscript() {
     var scheduleReport = new GlideRecord("sysauto_script");
     scheduleReport.get('0121c1733cc03010a2f3714242bc086c'); //Sys_id of the Scheduled job
     SncTriggerSynchronizer.executeNow(scheduleReport);
}

But I am getting an error of SncTriggerSynchronizer is not defined.

If I plug the exact code from the Scheduled Script into a Module - Script from Arguments, it will run fine, but returns to the Background Script screen, which is not the experience I want my users to have.

Thanks, in advance, for any help!

Jeanne

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

You can do the GlideAjax call as noted, or place the script you mention in your post in the processing script (server side) of the UI Page. That script is supposed to run server side, not client.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

7 REPLIES 7

AnirudhKumar
Mega Sage

Call a glideajax, and move the script to your script include.

Use glideajax in the Client Script and put the Schedule Script in a script include or the script above in a script include?

Allen Andreas
Administrator
Administrator

Hi,

You can do the GlideAjax call as noted, or place the script you mention in your post in the processing script (server side) of the UI Page. That script is supposed to run server side, not client.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

This is actually what I ended up doing to make it work. I had actually tried this first, and couldn't get it working. Turns out it really helps to have the button type set to "submit" vs. "sumbit". Sigh...