I want to update problem id short des into change request short desc using background script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
GlideRecord('incident');x.addQuery('number','INC0000011');x.query();if(x.next()){ gs.info(x.problem_id.getDisplayValue()); gs.info(x.problem_id.short_description.getDisplayValue()); GlideRecord('incident');x.addQuery('number','INC0000011');x.query();if(x.next()){ gs.info(x.problem_id.getDisplayValue()); gs.info(x.problem_id.short_description.getDisplayValue());
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
// Update Change Request short description with Problem short description (via Incident)
var cr = new GlideRecord("change_request");
cr.addNotNullQuery("incident"); // only CRs linked to an incident
cr.query();
while (cr.next()) {
var inc = new GlideRecord("incident");
if (inc.get(cr.incident)) {
if (inc.problem_id) {
var prb = new GlideRecord("problem");
if (prb.get(inc.problem_id)) {
cr.short_description = prb.short_description;
cr.update();
gs.print("Updated CR: " + cr.number + " with Problem short desc: " + prb.short_description);
}
}
}
}