The CreatorCon Call for Content is officially open! Get started here.

How to generate outage record automatically when incident is created

Rajamouly
Tera Expert

I am looking for a way to automatically generate an Outage record when Incident is created.

Aftre generate outage we need to set the 'Begin' & 'End' values from incident 'Actual start' & 'Actual end' fields.

Can any one help me on this requirement.

1 ACCEPTED SOLUTION

chrisperry
Giga Sage

Hi there,

This can be accomplished with an after insert business rule running on incident table. See below configuration:

find_real_file.png

find_real_file.png

Script:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var outageGr = new GlideRecord('cmdb_ci_outage');
    outageGr.initialize();
    outageGr.setValue('task_number', current.getUniqueValue());
    outageGr.setValue('type', 'outage');
    outageGr.setValue('cmdb_ci', current.getValue('cmdb_ci'));
    outageGr.setValue('begin', current.getValue('work_start'));
    outageGr.setValue('end', current.getValue('work_end'));
    outageGr.insert();

})(current, previous);

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

View solution in original post

4 REPLIES 4

chrisperry
Giga Sage

Hi there,

This can be accomplished with an after insert business rule running on incident table. See below configuration:

find_real_file.png

find_real_file.png

Script:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var outageGr = new GlideRecord('cmdb_ci_outage');
    outageGr.initialize();
    outageGr.setValue('task_number', current.getUniqueValue());
    outageGr.setValue('type', 'outage');
    outageGr.setValue('cmdb_ci', current.getValue('cmdb_ci'));
    outageGr.setValue('begin', current.getValue('work_start'));
    outageGr.setValue('end', current.getValue('work_end'));
    outageGr.insert();

})(current, previous);

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

Thanks Christopher for quick turn, it works for me hence marking as correct

HI Chrisperry,

 

I have an additional Requirement for this

 

Upon Incident Resolution, the assignee will fill out Actual Start/Actual End fields on the incident form and these fields will be populated automatically on the Outage record.

 

For this i have created after business rule, and mentioned the condition -- current.incident_state.changesTo (6)

Script:

 

(function executeRule(current, previous /*null when async*/) {

var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.setValue('begin', current.getValue('work_start'));
outageGr.setValue('end', current.getValue('work_end'));
outageGr.setValue('type', current.getValue('u_outage_record_type'));
outageGr.update();

})(current, previous);

 

Am i missing here anything?

BR1.jpg

BR2.jpg

  

Marida LH
Tera Contributor

Follow-up question on this thread: How do you ensure accurate Outage information (I couldn't see anything in the Xanadu release notes)?

 

As an IT Service Provider we are liable to potentially pay service credits and in some instances there can be quite severe implications where we fail to meet our Availability %'s. With such serious implications, you want accurate data and we know that where humans have to manually enter data, it is already at risk of not being accurate.

 

Has ServiceNow come up with a better solution since?