Update the priority field as T0 in business service table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 10:43 AM
Hi All,
There is a field on the impact analysis table as Recovery Tier. Whenever this is updated as "Tier 0". It should check the applies to field from the same table and find business application and from there check the downstream relationships and find business service. In business service table we need to update the priority field as T0.
I have written the below script, but it is not working. It is after update business rule. Please correct me if I am wrong.
(function executeRule(current, previous /*null when async*/) {
var appliesTo = current.applies_to;
// Ensure Applies To is a Business Application
if (appliesTo) {
var appRecord = appliesTo.getRefRecord();
if (appRecord && appRecord.sys_class_name == 'cmdb_ci_business_app') {
var grRel = new GlideRecord('cmdb_rel_ci');
grRel.addQuery('parent', appliesTo);
grRel.query();
while (grRel.next()) {
var childRecord = grRel.child.getRefRecord();
if (childRecord && childRecord.sys_class_name == 'cmdb_ci_service') {
childRecord.u_priority = 'T0';
childRecord.update();
}
}
}
}
})(current, previous);
Please assist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 02:42 AM
did you add gs.info() and see what came in logs?
1 change is there in your script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader