How to call Schedule job from Script include ?

Santosh Oraon
Tera Expert

Hello Team,

I have a requirement that from script include I want to trigger the Scheduled Job. In script include i have function that 

if my function return True then my schedule job got trigger and in that schedule job I have written gs.eventqueue(notification) that will be trigger after 30 min

1 ACCEPTED SOLUTION

@Santosh Oraon 

then why not write that scheduled job script within your script include?

no need to call schedule job then

if(function return value is true){

// your job script here

}

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

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Santosh Oraon 

check this script

//Execute a scheduled script job
var rec = new GlideRecord('sysauto_script');
rec.get('name', 'YOUR_JOB_NAME_HERE');
gs.executeNow(rec);
Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  can we call my function in Schedule job ?

@Santosh Oraon 

you call the schedule job; when schedule job runs it will run your script which has that function?

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

Santosh Oraon
Tera Expert

Requirement is like - In my script Include I have a function () if it returns Ture then this schduled job will run and trigger my Email notification also