populate manager name when Author and content woner is inactive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 09:35 PM
In kb artical when the Author and content woner (referance fields) is inactive how to populate their manager name when class is ITSM Level 2 Procedure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 10:25 PM
Hello @AT3 ,
Please try below script -
(function populateManagerName(kb) {
if (!kb.getValue('author') || !kb.getValue('author').isActive() && !kb.getValue('content_owner') || !kb.getValue('content_owner').isActive() &&
kb.getValue('kb_category') == 'it_procedures_level_2') {
var managerSysId = kb.getValue('author') ? kb.getValue('author').manager : kb.getValue('content_owner').manager;
var grMgrDetails = new GlideRecord('sys_user');
grMgrDetails.addQuery('sys_id', managerSysId);
grMgrDetails.query();
if (grMgrDetails.next()) {
kb.setValue('manager', grMgrDetails.getValue('name'));
}
}
})(current);
if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
CB