Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2025 12:49 AM
try this optimized code
(function executeRule(current, previous /*null when async*/) {
var businessApplicationSteward = current.getValue('u_cmdb_data_steward');
var businessApplicationStewardName = current.u_cmdb_data_steward.name+"";
var technicalApplicationOwner = current.getValue('u_custodian');
var technicalApplicationOwnerName = current.u_custodian.name+"";
var userID = gs.getUserID();
function note(field, stewardText, ownerText) {
if (current[field].changes()) {
if (userID == businessApplicationSteward) {
current.work_notes = stewardText + businessApplicationStewardName;
} else if (userID == technicalApplicationOwner) {
current.work_notes = ownerText + technicalApplicationOwnerName;
} else if (gs.hasRole('architecture_domain_admin') || gs.hasRole('architecture_domain_manager')) {
current.work_notes = "The " + field + " field has been updated by " + gs.getUserDisplayName() + ".";
}
}
}
note('u_business_application_type', 'The Business Application Type field has been updated by the Technical owner representative ', 'The Business Application Type field has been updated by the Technical Owner ');
note('short_description', 'The Description field has been updated by the Technical owner representative ', 'The Description field has been updated by the Technical Owner ');
note('u_end_date', 'The End Date field has been updated by the Technical owner representative ', 'The End Date field has been updated by the Technical Owner ');
note('u_new_application_reason', 'The New Application Reason field has been updated by the Technical owner representative ', 'The New Application Reason field has been updated by the Technical Owner ');
note('u_primary_capability', 'The Primary Capability field has been updated by the Technical owner representative ', 'The Primary Capability field has been updated by the Technical Owner ');
note('start_date', 'The Start Date field has been updated by the Technical owner representative ', 'The Start Date field has been updated by the Technical Owner ');
note('u_strategic_status', 'The Strategic Status field has been updated by the Technical owner representative ', 'The Strategic Status field has been updated by the Technical Owner ');
note('u_target_hosting_type_ref', 'The Target Hosting Type field has been updated by the Technical owner representative ', 'The Target Hosting Type field has been updated by the Technical Owner ');
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader