User need to run the scheduled job manually
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2023 02:22 PM
I know Scheduled Jobs will run manually by users who will have an admin role. But I have a request from my user that he needs to be run it when ever he wants to run/execute it. Is it possible? If yes, please help me with the detailed steps and script?
The scheduled job will run every 6 months. So if they want to run before 6 months they need to run or execute the scheduled job.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2023 03:46 PM
Hi @Sarah Bouil You can build some process here to solve this requirement.
You can fulfill this requirement either by asking user to submit a request and your request will auto execute the job.
Another approach, Build UI Page and allow user to manually select the schedule job to execute it from UI Page.
You can use server side function to solve this requirement.
SncTriggerSynchronizer.executeNow(current);
Let's see if you execute it via UI Page. This is how it will looks like .
UI Page Script:
HTML Part
<?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_reference name="my_var" query="active=true^name=RunnByNonITILUser" id="u_name" table="sysauto" style="width:70px"/>
<button type="button" onclick="runCode()">Execution</button>
</j:jelly>
Note: RunnByNonITILUser name is my schedule job name.
UI Page Client Script:
function runCode() {
var id = gel('my_var').value;
var ga = new GlideAjax('executeJob');
ga.addParam('sysparm_name', 'runScJob');
ga.addParam('sysparm_jobID', id);
ga.getXML(runaj);
function runaj(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
}
}
Script Include:
var executeJob = Class.create();
executeJob.prototype = Object.extendsObject(AbstractAjaxProcessor, {
runScJob: function() {
var id = this.getParameter('sysparm_jobID');
var grJob = new GlideRecord('sysauto_script');
if(grJob.get(id))
SncTriggerSynchronizer.executeNow(grJob);
},
type: 'executeJob'
});
Hope it will help you.
Feel free to reply me if you have any further questions for me.
Thanks,
Harsh
If my answer helped you, kindly select it as correct and close this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 03:35 PM
Hi Harsha,
After click on 'Execution' button nothing is happening.
1. How would I know whether my scheduled job is executed or not
2. I have selected the Scheduled Job name and clicked on Execution button, it should be process right but not.
3. I believe UI Page will not access by users, how canI allow them to excute it.
Please help me on above queries?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 07:02 PM
Hi @Sarah Bouil : If you have one specific job then in UI Page you can define it as default value. this way you don't need to change any ACL to allow non ITIL user to view it.
eg:
<g:ui_reference name="my_var" query="active=true^name=RunnByNonITILUser" id="u_name" table="sysauto_script" value="<Paste_schedule_JOB_sysID>" displayvalue="RunnByNonITILUser" style="width:70px"/>
Result: If you see below screenshot, you can see my scheduled job "RunnByNonITILUser" showing as default value.
Also I added my UI Page as "Module" (Run Scheduled Job) in filter navigator so, user can click on module and execute it.
Note: Once you will click on "Execution" button you can check the result in backend via adding logs in your scheduled jobs.
If you have scenario like, user want to select the job and want to execute then i would suggest build some catalog process and inside workflow you can use the below function , that way you can solve this as well.
SncTriggerSynchronizer.executeNow(current);
Hope it will help you.
Thanks,
Harsh