populate manager name when Author and content woner is inactive

AT3
Tera Contributor

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.

1 REPLY 1

chetanb
Tera Guru

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