View rule for change request for specific group to make default view

Chaithu3
Tera Contributor

Hi Experts,

 

The view for change form should be default to Default view for all the users, But the user from specific group X should be able to change the view but remaining all users including admin(if not part of X group) should not allow to change the view in form and list.

I have created a role called "ViewRoleChange" and assigned to X group.

Below is the code which i tried, Please help me ASAP with Fix,

 

(function overrideView(view, is_list) {
    var url = gs.action.getGlideURI().getMap();
    var sysId = url.get('sys_id');

    //access the GlideRecord of the currently viewed record
    var gr = new GlideRecord('change_request');
    gr.get(sysId);

    if (!gs.hasRole('ViewRoleChange')) {
        answer = "Default";
    }

})(view, is_list);
 
 
Thanks in advance.
Looping @Ankur Bawiskar 
 

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Chaithu3 

View rules are used to control views shown based on condition or script

you want to show which view if logged in user belongs to Group X?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

For all users, the default should be Default View, But the users is from X group then they can able to see all the views in the list, but the user is not belongs to X group then they want to see only Default view. It Should be applicable for both form and list of change request

 

 

Thanks

@Chaithu3 

are these 2 statements correct and please answer the question

So if logged in user belongs to group X then which view should be shown?

If logged in user doesn't belong to group X then it should be default view

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

if logged in user belongs to X group then the all views should be visible in list and set to default.

if the user is not belong to X group then it should default to Default View and only default view should be visible in list.

NOTE : It should apply for both form and list view.

Thanks