- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 08:08 AM
Upon Incident Resolution, the assignee will fill out Actual Start/Actual End and Outage Record type 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
Condition:urrent.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 anything here, Please help me.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 08:25 AM
Hi @Rajamouly ,
Your script is correct and you can create one incident and make it to In progress. Then update actual start and actual end, configuration and then resolve it.
It will update all the fields to that outage record.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 10:04 AM
Hi Mike,
I am just updating the outage record (Which is already created) here with the below code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:46 AM
in line 4, remove the quotes around current.sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 08:15 AM
Hi @Rajamouly ,
Script would something like below
Script:
(function executeRule(current, previous /*null when async*/ ) {
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('incidnet_refernce_field', sys_id); //you need to filter the outage which has same incident
outageGr.query();
if (outageGr.next()) {
outageGr.begin = current.work_start;
outageGr.end = current.work_end;
outageGr.type = current.u_outage_record_type;
outageGr.update();
}
})(current, previous);
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 09:25 AM
He Pavan,
Thanks for your response, i have modified the code as per your suggestion but still not working
(function executeRule(current, previous /*null when async*/) {
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('task_number','current.sys_id');
outageGr.query();
if (outageGr.next()) {
outageGr.begin = current.work_start;
outageGr.end = current.work_end;
outageGr.type = current.u_outage_record_type;
outageGr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:41 AM
If i remove Add Query & Query from script then it is creating the new record in Outage table rather to update.
Am i missing something here, please help?