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.

Visibility for Menu Item on Portal

babarat1
Tera Contributor

Hi All, I have a custom Menu item name "Test".

My requirement as follows:

1. I need to make it visible only for users who are part of a specific table

2. Example : there are multiple tables in Snow but I have a custom table "u_xyz". A logic should be applied that the instance analyzes the "logged in" user if he is part of the "u_xyz" table and if yes the "test" Menu item should be visible. Else it should not be visible.

babarat1_0-1677570911475.png

 

 

Need help to achieve the same. 

Thanks,

@Ankur Bawiskar @Community Alums @Allen Andreas @SatyakiBose @newhand 

1 ACCEPTED SOLUTION

@babarat1  you can just try this

 

var loggedIn = gs.getUserID();
var grgetUser = new GlideRecord('u_authorized_approver');
grgetUser.addQuery('u_user',loggedIn);
//grgetUser.addQuery('u_user.active','true');
grgetUser.query();
if(grgetUser.next())
return true;

else

return false;

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

View solution in original post

9 REPLIES 9

priyasunku
Kilo Sage

Hi @babarat1 

 

you can write a script include to check if the loggedin user is part of table 'XYZ' and call that script in the condition part of Menu item.

 

priyasunku_0-1677571710280.png

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

Hi,

Thanks for the reply Priya

can you share any reference script that can be used and should we call it using "javascript:" like in any other reference qualifiers/condtions.

TIA.

@babarat1  in the condition you can write it in this way

 

new ScriptIncludename.functionname()

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

@babarat1 

the same as @priyasunku 

 

newhand_0-1677572225647.png

 

newhand_1-1677572246727.png

 

 

Please mark my answer as correct and helpful based on Impact.