How to make manager have the view of Employees that they manage?

Achyuth Krishna
Tera Contributor

My manager has different employees from different regions(Countries).  We have Knowledge articles visible based on the region they are in. How can we make manager see the knowledge articles of employees that he manage on Employee Center Portal?

 

 

 

 

 

3 REPLIES 3

Krista Terban
ServiceNow Employee
ServiceNow Employee

I would also check out the manager hub functionality which is HR Pro functionality- this is delivered functionality in Manager Hub https://docs.servicenow.com/bundle/vancouver-employee-service-management/page/product/employee-cente...

Revanth Karra
Tera Expert

Dear Achyuth Krishna,

 

Hope you're doing great!

 

@Achyuth Krishna ,

 

METHOD 1:

Use the Employee Center Knowledge Articles widget

The Employee Center Knowledge Articles widget allows you to display knowledge articles to employees based on their manager. To use this widget, follow these steps:

  1. Navigate to the Employee Center Portal.
  2. Click the Add Widget button.
  3. Select the Employee Center Knowledge Articles widget.
  4. Configure the widget to display the knowledge articles of employees that the manager manages.
  5. Click the Save button.

 

METHOD 2:

Use a custom script

You can also use a custom script to display the knowledge articles of employees that the manager manages on the Employee Center Portal. To do this, you can use the following steps:

  1. Create a new custom script.
  2. Add the following code to the script:

 

 

// Get the manager's employees.
var employees = gs.getUser().getEmployees();

// Get the knowledge articles of the manager's employees.
var knowledgeArticles = [];
for (var i = 0; i < employees.length; i++) {
var employee = gs.getUser().getRecord(employees[i]);
var knowledgeArticleRecords = GlideRecord('kb_knowledge');
knowledgeArticleRecords.addQuery('assigned_to', employee.sys_id);
knowledgeArticleRecords.query();
while (knowledgeArticleRecords.next()) {
knowledgeArticles.push(knowledgeArticleRecords);
}
}

// Display the knowledge articles.
// You can use any method to display the knowledge articles, such as using the GlideRecord.displayValue() method or by rendering a custom widget.

 

      3. Attach the custom script to the Employee Center Portal.

 

Once you have implemented one of these methods, the manager will be able to see the knowledge articles of employees that they manage on the Employee Center Portal.

 

TIPS:

  • You can use the gs.getUser().getRoles() method to get the manager's roles. This can be useful if you want to display different knowledge articles to managers based on their roles.
  • You can use the GlideRecord.addEncodedQuery() method to filter the knowledge articles that are displayed to the manager. This can be useful if you want to display only knowledge articles that are relevant to the manager's employees or to the manager's roles.
  • You can use the GlideRecord.orderBy() method to sort the knowledge articles that are displayed to the manager. This can be useful if you want to display the knowledge articles in a specific order, such as by the most recently updated knowledge articles first.

 

Kindly, please mark my solution as Helpful/Correct, if applicable. If I could help you with your Query then, please hit the Thumb Icon and mark as Correct!!!

 

Thanks & Regards, 

Revanth. K

Product Test Automation Engineer

Alex87
Tera Contributor

Just include the script in the knowledge read criteria's. Thats how we solve it. Easy and no complex coding on OOTB widgets.