Create incident from scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 04:38 AM
Hi
yesterday Chuck started me ok with this script:
var rec = new GlideRecord('u_infrastructure_certificates');
rec.query();
while (rec.next()) {
var now = new GlideDateTime();
var gdt = new GlideDateTime();
gdt.setValue(rec.getValue('u_cert_expiry_date'));
gdt.addWeeksLocalTime(-6);
if (gdt.getNumericValue() < now.getNumericValue()) {
// Expires in 6 weeks or less - do something here
}
}
Not being a scripter please help:
a: how do I change this so it only applies it to the record if the date is exactly 30 days
b: How do I get it to add the below so it creates the incident
var gr = new GlideRecord('incident');
gr.intialize();
gr.short_description = 'Certificate renewal required';
gr.assignment_group = '5e8550e90f6e3900f6e783fc22050ef3';
gr.description = current.u_subject_name;
//gr.cmdb_ci = 'Certificate Services (Corporate Internal)';
gr.setDisplayValue('cmdb_ci','Certificate Services (Corporate Internal)');
//gr.u_inf_certificate = current.number;
gr.u_inf_certificate = current.sys_id;
gr.insert();
Help much appreciated
Thanks,
Riaz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 05:55 AM
Thank Chuck I will play around this a lot its a great start
riaz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2017 05:54 AM
Just to update on this. Christoper Jhonson from the community supplied the correct script from another post
- var chkDate = new GlideDate();
- chkDate.addDays(30);
- var rec = new GlideRecord('u_infra_certificates');
- rec.addQuery('u_cert_expiry_date', chkDate);
- rec.query();
- gs.print(rec.getRowCount());
Thanks,
Riaz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 12:54 PM
and this script of yours I think would be the solution, would you be so kind to paste the full version that today is working with 30 days so based on the same I see to modify them for our need.