Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to hide "View all request" dropdown on menu items in Service Portal

rubesh_u
Tera Expert

I am able to display the count by using out of box menu item script. How to hide the "view all items". I want to directly go to the list page not the dropdown. how to hide that ? I tried removing that part of code but that doesn't work !

This is the code : 

var max = 30;
var t = data;
t.items = [];
t.count = 0;

var currentUserEmail = gs.getUser().getEmail();

// record watchers: listen for changes to this custom table
t.record_watchers = [];
t.record_watchers.push({
  'table': 'x_1097288_hacktaho_hackathon_team',
  'filter': 'external_user_email_idsLIKE' + currentUserEmail
});

// Query hackathon teams where user is involved
var gr = new GlideRecord('x_1097288_hacktaho_hackathon_team');
gr.addQuery('external_user_email_ids', 'CONTAINS', currentUserEmail);
gr.orderByDesc('sys_updated_on');
gr.setLimit(max);
gr.query();

// Add "View All My Teams" link
var link = {};
link.title = gs.getMessage('View all my Hackathon Teams');
link.type = 'link';
link.href = '?id=my_team_requests'; // <-- create a page for this or direct to list view
link.items = [];
t.items.push(link);

while (gr.next()) {
  var a = {};
  a.team_name = gr.getValue('team_name');
  a.hackathon = gr.hackathon.getDisplayValue();
  a.external_users = gr.getValue('external_user_email_ids');

  $sp.getRecordValues(a, gr, 'sys_id,sys_updated_on');
  a.type = 'hackathon_team';
  t.items.push(a);
  t.count++;
}

// Badge count for header
if (t.count == 1)
  data.badgeHint = gs.getMessage('{0} team found', [''+t.count]);
else
  data.badgeHint = gs.getMessage('{0} teams found', [''+t.count]);

 

11 REPLIES 11

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @rubesh_u 

I think this might negatively impact the user experience. There's a reason ServiceNow includes these types of dropdowns—so users can easily click and view details. Let's not create a technical workaround that complicates the system unnecessarily.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

ChrisBurks
Giga Sage

Hi @rubesh_u ,

 

Out of box this is not possible. The type of menu item that allows a count to display via a script is a scripted list. By default it's saying you want to display a "list" of items as a dropdown. 

If you don't mind not displaying a count then change the type of menu item it is. 

But if you need the count to be there then you'll have to customize your menu item in a way as to not display a list but display a count.