The CreatorCon Call for Content is officially open! Get started here.

Set the Custom view to default view when an IT team user open User form.

RajeshS45028713
Tera Contributor

 

Hi Community,

I have created a custom form view specifically for IT team users. My goal is that whenever they open the User module form—whether for an existing user or when creating a new user—this custom view should be set as the default view for them, and they should not be able to change it.

What I’ve tried so far:

  1. View Rule (by assigning a custom role to the IT team):

 

 
(function overrideView(view, is_list) { var isLimitedUser = gs.hasRole("limited_user_creator"); if (isLimitedUser) { answer = "User View For IT"; } else { answer = view; } })(view, is_list);

 

 
  1. OnLoad Client Script:

 

 
(function onLoad() { // Check if the user has the IT role if (g_user.hasRole('limited_user_creator')) { g_form.setView('user_view_for_it'); } })();
 

Result:
Both approaches are not working as expected.

I would greatly appreciate it if anyone who has solved a similar issue could share their solution or guidance.

Thanks,
Rajesh

1 REPLY 1

Bhavya11
Kilo Patron
Kilo Patron

Hi @RajeshS45028713 ,

 

in view rule script

(function overrideView(view, is_list) {

        var isLimitedUser = gs.hasRole("limited_user_creator");
        if (isLimitedUser) {
            answer = "user_view_for_it";// name of view instead of Title
        } else {
            answer = view;
		}
    
})(view, is_list);

 

Thanks,

BK