- 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 05:08 AM
That would be done with a reference field. If you want the incident to reference the original record, you can create a reference field on the incident (e.g. u_cert) that points to your cert table and populate the field in the script before you do the inc.insert().
inc.u_cert = current.sys_id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 05:11 AM
PerfectThanks Chuck

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 05:13 AM
You are welcome Riaz,
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 05:15 AM
Thank you again Chuck -