Write a Condition that Hides Items in SP Menu

codechaser
Giga Expert

Looking for a condition that will hide items from displaying in the Service Portal Header Menu.  Right now, I have something that looks like this... GlideSPScriptable.canSeePage("services_status") && gs.getUser()... but need to restrict access, based-on those who are a member of a Department.

Thank you!

1 ACCEPTED SOLUTION

Condition should be GlideSPScriptable.canSeePage("services_status") && new bsu_system_status().getMyDepartmentID()

Use below script

var bsu_system_status = Class.create();
bsu_system_status.prototype = {
initialize: function() {

},

getMyDepartmentID: function() {
if (gs.getUser().getDepartmentID() == 'sysID1' || gs.getUser().getDepartmentID() == 'sysID2' || gs.getUser().getDepartmentID() == 'sysID3')
return true;
else
return false;
},
type: 'bsu_system_status'
};


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

10 REPLIES 10

SanjivMeher
Kilo Patron
Kilo Patron

You can write

GlideSPScriptable.canSeePage("services_status") && gs.getUser().getDepartmentID() == 'sys_id of the department who should see status page'


Please mark this response as correct or helpful if it assisted you with your question.

This works but am curious if you can include multiple departments in the same condition and what that might look like?

Thanks again!

GlideSPScriptable.canSeePage("services_status") && (gs.getUser().getDepartmentID() == 'sys_id1' || gs.getUser().getDepartmentID() == 'sys_id2' || gs.getUser().getDepartmentID() == 'sys_id3')


Please mark this response as correct or helpful if it assisted you with your question.

Thanks!  Oddly enough, it doesn't work for the other two groups, but does for the one.  Perhaps a function call would be easier?