Apply User Criteria to Service Portal Menu or Menu Item

John Shores1
ServiceNow Employee
ServiceNow Employee

We're launching our first service portal this fall. One thing we'd like to do is offer those people who have fulfiller roles in the system a way to link from the portal to the native UI to complete their work.

  • Our first idea was to add a menu item to the default SP Header Menu and restrict that items visibility to only those with fulfiller roles.
  • Our second idea was to create a new menu and restrict its visibility to those with the appropriate role.
  • Our third idea was to add a widget to the page and restrict its access as above.

From what I can tell, there's no OOB way to apply user criteria to a menu or a menu item (bummer). So short of adding a single purpose widget, how are you solving for this use case?

Thanks in advance for your thoughts!

John

1 ACCEPTED SOLUTION

Patrick Fedigan
Giga Guru

Hello John,

A menu item is a great idea! I would create a new menu item in the SP Header Menu with a condition that the user has an ITIL role. I tested this in my dev instance with success. Here are some screenshots to help:

find_real_file.png

find_real_file.png

Cheers,

View solution in original post

7 REPLIES 7

Hi Dave,

We didn't actually, we ended up using roles to restrict the header menu. 

We did create some advanced User Criteria for each country which has helped restricting widgets. (If this any use to you)

countryIsUK();
 function countryIsUK(){
	var flag = false;
	var gr = new GlideRecord('sys_user');     
	gr.addQuery("sys_id", gs.getUserID());     
	gr.query();     
	if (gr.next()) {
		if(gr.building.u_country == "ed966f2ff067c0007c1b7af45b498057"){// UK
			   flag = true;     
		} else {   	    
		} 
	}
	return flag;
}

Best way for this would be to call the user criteria from within a script include, then simply pass that user record to the script include to do the check to see if they meet the user criteria. Unfortunate part about the condition builder in portal is that it's not intuitive. It's just a string field :). 

Jeremy Duncan1
Kilo Contributor

FWIW, you could also check if user has any roles by doing the following: gs.getUser().hasRoles();

Nother suggestion - might want to check that HREF / URL so that it's not aimed at your DEV instance, as this won't follow you when moving to UAT/PROD. Best practice would be doing a forward slash (/) with the rest of the URL. 

 

find_real_file.png