need to auto populate impacted services from affected cis in the related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2019 08:03 PM
I need to auto-populate impacted services from affected cis in the related list.
I have written a display BR below which is not populating services, Can you tell me what's missing?
function onDisplay(current, g_scratchpad) {
removeAffectedServices(current);
if (!current.cmdb_ci.nil()) {
addAffectedServices(current);
}
}
function removeAffectedServices(current) {
var m2m = new GlideRecord('task_cmdb_ci_service');
m2m.addQuery('task',current.sys_id);
m2m.addQuery('manually_added','false');
m2m.query();
m2m.deleteMultiple();
}
function addAffectedServices(current) {
var affectedItem = new GlideRecord('task_ci');
affectedItem.addQuery('task', current.sys_id);
affectedItem.query();
var aff_ci;
while (affectedItem.next()) {
aff_ci = affectedItem.ci_item.toString();
var ciu = new CIUtils();
var services = ciu.servicesAffectedByCI(aff_ci);
var m2m = new GlideRecord('task_cmdb_ci_service');
for (var i = 0; i < services.length; i++) {
m2m.initialize();
m2m.task = current.sys_id;
m2m.cmdb_ci_service = services[i];
m2m.manually_added = 'false';
m2m.insert();
}
}
}
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2019 08:52 AM
Hi Ankur,
Can you help please?
Regards,
Archie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2019 06:48 PM
Hi Archie,
Did you check the related list table is a m2m table? Are you populating it via script?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader