I want to update problem id short des into change request short desc using background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 05:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 07:06 AM
Hi @TanujB
Try the below script..
var inc = new GlideRecord('incident');
inc.addQuery('number','INC0000506');
inc.query();
if(inc.next()){
inc.short_description = inc.problem_id.short_description;
inc.update();
}
Regards,.siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 07:16 AM - edited 07-23-2025 07:19 AM
Hi @TanujB ,
you want to update the change short description? then use this script
var incGr = new GlideRecord('incident');
if (incGr.get('number', 'INC0000011')) {
gs.info(incGr.problem_id.getDisplayValue());
gs.info(incGr.problem_id.short_description);
var chgGr = incGr.rfc.getRefRecord();
if (chgGr.isValidRecord()) {
chgGr.short_description = incGr.problem_id.short_description;
chgGr.update();
}
}
if you want to update the problem short description from change short description use this
var incGr = new GlideRecord('incident');
if (incGr.get('number', 'INC0000011')) {
gs.info(incGr.problem_id.getDisplayValue());
gs.info(incGr.problem_id.short_description);
var prbGr= incGr.problem_id.getRefRecord();
if (prbGr.isValidRecord()) {
prbGr.short_description = incGr.rfc.short_description;
prbGr.update();
}
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 07:27 AM
Hello @TanujB ,
You're trying to copy the Problem's short description into the Change Request's short description so please you the script below and see how it works for you and the logs will help you to understand the execution as well, so try to debug if anything goes wrong based on the logs also make sure your change req record reference is stored in rfc field only if you're using any other like "Parent" so just update that in the below script.
var incGR = new GlideRecord('incident');
if (incGR.get('number', 'INC0000011')) {
var probGR = incGR.problem_id;
var rfcGR = incGR.rfc; // Assuming 'rfc' is a reference to Change Request
if (probGR && rfcGR) {
var changeGR = new GlideRecord('change_request');
if (changeGR.get(rfcGR)) {
changeGR.short_description = probGR.short_description;
changeGR.update();
gs.info('Updated Change Request short description with Problem short description.');
} else {
gs.info('Related Change Request not found.');
}
} else {
gs.info('Either Problem or RFC reference is missing.');
}
} else {
gs.info('Incident not found.');
}
🔹 Please mark ✅ Correct if this solves your query, and 👍 Helpful if you found the response valuable.
Best regards,
Aniket Chavan
🏆 ServiceNow MVP 2025 | 🌟 ServiceNow Rising Star 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 05:44 AM
Hello @TanujB ,
Just wanted to check in to see if my earlier response helped you out or if you're still facing any issues. If your query is resolved, it would be great if you could mark my reply as helpful and accept it as the solution — that way it can also benefit others who come across the thread later.
Also, if you found any other responses helpful, feel free to mark those as helpful too. You can even accept multiple solutions if they contributed to resolving your issue.
Let me know if you need anything else!
Best regards,
Aniket Chavan
🏆 ServiceNow MVP 2025 | 🌟 ServiceNow Rising Star 2024