- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 12:46 PM
Good afternoon,
I'd like to set a condition on a megamenu item based on a value in a field in sys_user (instead of something like group membership or hasRole).
Ideally I'd like to expose the menu item for employees where u_primary_division != "xxx"
I tried to use gs.getUser for this, but I think I'm misusing it. Any thoughts on how to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 02:03 PM
I was able to meet the business case by using conditional checks against hasRole after all -- this is resolved. Thanks again for the suggestion!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 01:04 PM
Hi,
Write below code in script include and call it in function
var loggedIn = gs.getUserID();
var grgetUser = new GlideRecord('u_authorized_approver');
grgetUser.addQuery('u_user',loggedIn);
//grgetUser.addQuery('u_user.active','true');//add your query
grgetUser.query();
if(grgetUser.next())
return true;
else
return false;
Select type page and define Condition field like below
Call script include and function :
new ScriptIncludeName().function()// replace with your script include and function name
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks & Regards,
Sumanth Meda.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 01:56 PM
Thanks for the quick response, however I don't think this will achieve the desired solution.
Can a simple condition which checks against a value in the user profile not be applied directly in the menu item?
What is the line "var grgetUser = new GlideRecord('u_authorized_approver');" doing in the script above?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 02:01 PM
Hi,
Please replace with your table name (or) sys_user.
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 02:03 PM
I was able to meet the business case by using conditional checks against hasRole after all -- this is resolved. Thanks again for the suggestion!