- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 01:23 AM - edited ‎12-07-2023 02:25 AM
Hi All,
Can anyone please us on the below script:
We wrote one script include and client script to hide the Related list, If the user/manager don't have any direct reporters. But some reasons it's not wokring for us, can anyone please check and let us know where we went wrong.
Script include:
return userCount++;
Client script:
}
Advance thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 01:43 AM
Sorry my bad,
Please update script include like this:
var getManagerDirectReports = Class.create();
getManagerDirectReports.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getActiveUsers: function(managerSysID) {
var manId = this.getParameter('manager_id');
var usr = new GlideRecord('sys_user');
usr.addQuery('manager', manId); // updated query
usr.query();
return usr.getRowCount();
},
type: 'getManagerDirectReports'
});
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 01:45 AM
try this too:
g_form.hideRelatedList() not working - Support and Troubleshooting (servicenow.com)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 01:31 AM
Hi,
Update your script include part like below:
var getManagerDirectReports = Class.create();
getManagerDirectReports.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getActiveUsers: function(managerSysID) {
var manId = this.getParameter('manager_id');
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id', manId);
usr.query();
return usr.getRowCount();
},
type: 'getManagerDirectReports'
});
And update your onLoad client script like below:
function onLoad() {
var usrs = new GlideAjax('getManagerDirectReports');
usrs.addParam('sysparm_name','getActiveUsers');
usrs.addParam('manager_id',g_form.getUniqueValue());
usrs.getXML(callbackfunction);
function callbackfunction(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer); // Example: If one user have two reporting users but in alert we're getting zero
if(answer == 0)
{
g_form.hideRelatedList('direct_reports');
}
else{
g_form.showRelatedList('direct_reports');
}
}
}
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 01:39 AM
HI Anil,
Thanks for the response.
Tried your suggestions, In one scenario user have two reporting users but in alert we're getting only one.
Advance thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 01:41 AM
Check user status, another user must be deactivated (active=false).
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 01:46 AM
HI Anil,
Thanks again.
We thought the same but the reporting users are active only and one more thing there is one user with no direct repoters but in alert we're getting one as well.
Advance thanks.
