servicenowservicenow-rest-api

How to display record in custom created related list of all users having same manager in servicenow


I want to display the record in custom created related list of all users having saming manager in servicenow. For e.g. Abel, Jack has manager Adel, so when I open Adel record I should be able to see the Abel user and Jack user.

This is the script I used and don't know how it will execute in related list:

var gr = new GlideRecord('sys_user');
gr.addQuery('user_name','abel');
gr.query();
gr.next();
gs.print(gr.getDisplayValue('manager'));

I tried this is in Scripts Background option in Application Navigator


Solution

  • You shouldn't need to code for this. If you want to add a related list of user's the current user manages. It will list as "Users" but you can change that label in the related list configuration.

    Open menu to add related lists Add the related list

    If you meant to do this by code, you'd need to a scripted relationship the data. Here's some information on that. https://docs.servicenow.com/bundle/newyork-platform-user-interface/page/administer/form-administration/task/t_CreateDefinedRelatedLists.html