- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2016 08:01 PM
Hi Everyone,
We have a requirement from the client that whenever a new record is inserted into a table, the business rule would run to create a schedule job that would only run once at the set time.
Basically every record in this table would contain a time field.
ex: Name Time
Record 1. Amy 12/5/2016 12:00
Record 2. Jean 22/5/2016 08:00
Record 3. James 20/5/2016 07:00
Whenever someone create a new record, a new schedule job should be created, set to run script, run only once and start at the specific time we enter for that record.
So if we create the three records above, three schedule jobs should be created and run once at the time specified in the time field above.
I am very new to scripting in ServiceNow so just wondering if there is any script that is for create new schedule job and set parameters as well?
Thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2016 08:28 PM
Hi Kiki,
Yes, this can be done. What sort of scheduled job are you looking for? A report? A script? You can run an AFTER business rule to insert a new record in the sysauto_script table (for a script.) If you want to run some other job, let me know.
Something like this (untested)
Name: Create new scheduled job
When: After
Table: (your table full of records)
Insert: true
Update: false
Advanced: true
Condition: (empty)
Script:
function onAfter(current, previous) {
var s = new GlideRecord('sysauto_script');
s.newRecord();
s.name = current.name;
s.active = true;
s.run_type = 'once';
s.run_start = current.time;
s.script = '// Insert your Javascript here';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2017 01:48 AM
Yes it does still work in Jakarta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2018 09:34 PM
Hello Chuck,
I have similar requirement like kiki had but few additional things like i have column called Frequency which can be anything like one record might have MON,TUE other record might have Weekly some record might have Daily and also having time zone. Could you please suggest a way to achieve it ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2018 05:13 AM
Unfortunately, I don't have enough information about your requirements and data model to suggest an answer. To get better visibility, I recommend posting a new question with the following:
- What are you trying to accomplish (technically)
- What are the underlying requirements/business drivers?
- What have you tried?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2018 08:56 PM
Hello Chuck,
I have similar requirement like Kiki had where record will be inserted through service catalog but in addition there is one field in my table which is frequency so if one record is having frequency Mon,Tue so schedule job should run on Mon,Tue if other record is having frequency as Wed,Thu and Fri then it should run at this time. I have written BR as per your suggestion which is creating a new schedule job after every new insertion in the custom table and also i have set name, time, script, timezone in schedule job now i want to write a condition in schedule job where it will check the frequency column in my custom table and run according to that. In addition i have created a field called Job ID in my custom table which will store sys_id of newly created schedule job.
Could you please help me with this as i am new to ServiceNow development. ?
I have already created a new post https://community.servicenow.com/community?id=community_question&sys_id=cf63636cdb952300a39a0b55ca961944&view_source=searchResult
Thanks a lot for your help in advance !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2020 02:19 AM
Hi Chuck,
I am getting below error while execute an notification event from Scheduled Job.
Invalid query detected, please check logs for details [Unknown field u_owner_group in table sysauto_script]
u_owner_group field is a custom field on the sc_cat_item table. Please let me know if anything i am missing.
see below steps i am following
Please let me know if i am missing anything.
Thanks,
Antony