Menu Item Condition Based on user record field value?

lawrencemgann
Tera Guru

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?

 

lawrencemgann_0-1707770701334.png

 

1 ACCEPTED SOLUTION

lawrencemgann
Tera Guru

I was able to meet the business case by using conditional checks against hasRole after all -- this is resolved.  Thanks again for the suggestion!

View solution in original post

4 REPLIES 4

Sumanth16
Kilo Patron

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.

lawrencemgann
Tera Guru

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?

Hi, 

 

Please replace with your table name (or) sys_user.

 

Thanks & Regards,
Sumanth Meda

lawrencemgann
Tera Guru

I was able to meet the business case by using conditional checks against hasRole after all -- this is resolved.  Thanks again for the suggestion!