Write a fix script to update Watchlist members
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team,
My requirement :
Create fix script to update watchlist with (if not already included) the POCs for an APM included in all new CIRs.
IT App Owner
IT Support Manager
Technical Primary SME
Enterprise Architect
We need to update the listing contacts for all open CIRs to ensure current contacts/owners are included.
I have written below Script in the record Producer , it's working for newly created request
but I want to write fix script to update watchlist for existing requests
current.watch_list = current.cmdb_ci_business_app.owned_by + "," + current.cmdb_ci_business_app.it_application_owner + "," + current.cmdb_ci_business_app.u_it_primary_contact + "," + current.cmdb_ci_business_app.u_technical_primary + "," + current.cmdb_ci_business_app.u_technical_secondary_2 + "," + producer.watch_list;
Help me to write fix script for existing CIRs
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @JVINAY
var grTable = new GlideRecord(tablename);
//add query condition as per requirement
grTable.query();
var updated = 0;
while (grTable.next()) {
if (!grTable.cmdb_ci_business_app) {
continue;
}
var app = grTable.cmdb_ci_business_app.getRefRecord();
if (!app) {
continue;
}
var wl = [];
if (grTable.watch_list) {
wl = grTable.watch_list.split(",");
}
if (app.owned_by && wl.indexOf(app.owned_by.toString()) == -1)
wl.push(app.owned_by.toString());
// do this for all the fields
var newList = wl.join(",");
if (newList != grTable.watch_list) {
grTable.watch_list = newList;
grTable.update();
updated++;
}
}
gs.info("Updated: " + updated + " CIRs");