- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2021 09:07 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2021 09:26 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 03:42 AM
Hi Jeanne,
Could you please share the script?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 08:01 AM
I created a UI Page that only has a button. The page is accessed as a Module from the filter navigator. The UI page has the following code in the HTML section:
<?xml version="1.0" encoding=utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<table class=wide">
<tr>
<td nowrap="true">
<g:dialog_button id="ok_button" type="submit" style_class="btn btn-primary">${gs.getMessage('Generate Report and Send Notifications')} </g:dialog_button>
</td>
</tr>
</table>
<input type="hidden" id="btn_clicked" name="btn_clicked" value="OK"></input>
</g:ui_form>
</j:jelly>
And in the Processing Script section has the following code:
var scheduleReport = new GlideRecord("sysauto_report");
scheduleReport.get('0121c1733cc03010a2f3714242bc086c'); //sys_id of the Open Training Tickets report
var recipients = []; //array for managers of users with open training tickets
var tablename = scheduleReport.report.table;
var lookup = scheduleReport.report.filter;
var gr = new GlideRecord(tablename);
gr.addEncodedQuery(lookup);
gr.query();
while(gr.next()) {
recipients.push(gr.assigned_to.manager.toString());
}
var arrayUtil = new ArrayUtil();
var finalRecipients = arrayUtil.unique(recipients);
scheduleReport.user_list = finalRecipients.join(','); //get unique recipients
scheduleReport.update();
SncTriggerSynchronizer.executeNow(scheduleReport); //execute schedule report
gs.addInfoMessage('Report has been generated and email notifications sent.');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 04:07 AM
I appreciate your help Jeanne! Thank you so much!