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.

cannot see the View in the dropdown menu after set a View Rule

ShuRiseUp2023
Tera Expert

I set a View Rule to set a view (like view 1) as the default view. After I set the View Rule, I cannot find the View menu from the drop down menu on the form. How to still show the View menu and allow switch different views? 

ShuRiseUp2023_0-1734128322909.png

 

1 ACCEPTED SOLUTION

Hi @ShuRiseUp2023 ,

 

Can you please try this instead?

if (gs.hasRole("admin")) {
		return; // do nothing admin users
    } else {
              if(gs.getUser().isMemberOf("Group Name")){
             //gs.info("set default view to Sprint 0 for users in Group Name);
              answer = "view_name";}
              else if (!gs.hasRole("admin")){
             //gs.info("set default view to Default for non-admin users");
              answer = '';}
     }

 

If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das

View solution in original post

2 REPLIES 2

ShuRiseUp2023
Tera Expert

I set advanced view rule to let null default view to admin users so the admin can still be able to switch views, the code is like: 

if(gs.getUser().isMemberOf("Group Name")){
        //gs.info("set default view to Sprint 0 for users in Group Name);
        answer = "view_name";
    }else if(!gs.getUser().hasRole("admin")){
        //gs.info("set default view to Default for non-admin users");
        answer = '';  
    }else{
        //gs.info("don't set any default view for admin users");
        answer = null;
    }
Hope it helps to others. 

Hi @ShuRiseUp2023 ,

 

Can you please try this instead?

if (gs.hasRole("admin")) {
		return; // do nothing admin users
    } else {
              if(gs.getUser().isMemberOf("Group Name")){
             //gs.info("set default view to Sprint 0 for users in Group Name);
              answer = "view_name";}
              else if (!gs.hasRole("admin")){
             //gs.info("set default view to Default for non-admin users");
              answer = '';}
     }

 

If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das