- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 04:07 AM
Hello,
I have create a new table to capture Infra Certificates and one of the fields is Expiry Date.
I would an Incident to be created and assigned to a specific group 6 weeks before the Expiry Date is reached.
Can some help me and explain what needs to be done?
If any scripting needs to be done it would be useful to have a few lines of code as I am not experienced in this.
Thanks
Riaz
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 04:35 AM
Hi Riaz,
You're going to need to create a scheduled job that runs a small script. Here's a starting point for you.
http://wiki.servicenow.com/index.php?title=Creating_a_Scheduled_Job
var rec = new GlideRecord('YOURTABLE');
rec.query();
while (rec.next()) {
var now = new GlideDateTime();
var gdt = new GlideDateTime();
gdt.setValue(rec.getValue('YOUR EXPIRY FIELD NAME'));
gdt.addWeeksLocalTime(-6);
if (gdt.getNumericValue() < now.getNumericValue()) {
// Expires in 6 weeks or less - do something here
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 04:44 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 04:49 AM
That's the general idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 04:52 AM
Sorry what I meant was have i selected the correct information here? Or would you recommend i just recreate the table and extend with the Task table?
It is a new table so no records...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 04:58 AM
I don't think you need to recreate the table from Task in this case.
If you can create a workflow, you can always use the Run Script activity to generate a record on (almost) any table as well.
Ex:
var inc = new GlideRecord('incident');
inc.newRecord();
inc.assignment_group.setDisplayValue('NAME OF YOUR ASSIGNMENT GROUP');
inc.short_description = 'SOME DESCRIPTION';
inc.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 05:04 AM
Thanks Chuck that is great but then how do I relate any of the information from that Record back to the Incident?