- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 11:57 PM
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.
Need help to achieve the same.
Thanks,
@Ankur Bawiskar @Community Alums @Allen Andreas @SatyakiBose @newhand
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 12:46 AM
@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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 12:16 AM - edited 02-28-2023 12:20 AM
Hello @babarat1
One way to achieve this:
- Set the menu item type = page
- Under the condition you can call a script include like this:
new ScriptIncludeName().function(); - In the script include, you can write the function as: (this script is just for reference. you can modify it as per your business requirement)
getMenuItem: function() {
var gr = new GlideRecord('asmt_assessment_instance');
gr.addQuery('user', gs.getUserID());
gr.addEncodedQuery('stateINready,wip');
gr.addEncodedQuery('metric_type.evaluation_methodINattestation_v2,risk_assessment,vdr_risk_asmt');
gr.query();
var re = new GlideRecord('sn_risk_advanced_event');
re.addQuery('opened_by', gs.getUserID());
re.addEncodedQuery('stateNOT IN4,3');
re.query();
return (gr.next() || pe.next()) && gs.isLoggedIn();
}
You can change the table name and query conditions as per the tables in your instance.
Also keep in mind, that if the menu item is supposed to show a list of record, then you have a portal page defined where this list would be available.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 12:34 AM
How do I return the value from here sir?
I have the script and it returns the sysid of the user
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()){
gs.print(loggedIn);
gs.print("user "+grgetUser.u_user);
}
i do not know what to return from here
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 12:36 AM
@babarat1 you can just return true or false.
if record exists return true. if not return false.
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 12:46 AM
@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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 12:41 AM
It depends on what data are you trying to match.
This line of code, doesn't seem quite right.
grgetUser.addQuery('u_user',loggedIn);
Is the u_user field a reference field to the sys_user table?
Basically you will have to find a field in both the tables - your custom table, and sys_user table that you can map to for validation of the user.