- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2021 11:59 PM
Hi, experts.
I would like to fix View by user role.
I have created one user and one role and assigned that role to that user.
I would like to do the following.
1. I would like to create a view that only that user can use.
2. If that user is in control, the view will appear on the screen.
3. However, if the controller is not that user, then the view cannot be used.
4. (if possible) It cannot be changed from its default view if that user is in control.
Please give me your hand.
I'm not good at English, If these sentences is hard to read for you, I'm apologize.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2021 05:22 AM
You can go to the UI views under the System UI look for your View in list, Open the record and you will be able to see. If no role is assigned then by default views are visible to Admin or Itil-user since they have access to create view and control them.
If you don't want admin to have access to the view you need to write another If statement and add the gs.hasRole("admin") and answer=false. Only this way you can revoke the admin access to views. As being admin, all access is available to them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2021 09:48 AM
Hi,
Please follow below steps to achieve your requirement:
1) Navigate to "Views" module to create a new View for your requirement mentioned in step 1.
2) Click on New button.
3) Enter a valid name say "Specific" and give the same name in Title field as well as shown below:
Make sure the name is in lowercase only.
4) Now The View is created, so you can go ahead and add your Form and List Elements(Fields) which you want for your user to be shown as mentioned below:
For example I have created a List record and added List elements as shown below:
Within this add the List elements as shown below:
Now for your requirement, to make this new View available only to a specific Role, you just need to add the Role in the View form itself to restrict this view become available only to Users having the custom role you have created. Refer to screenshot below, this is the same as my first screenshot:
So you don't need to create a View Rule and just make use of this Role field to achieve what you want.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2021 05:30 PM
Thank you for polite reply.
How do I check if user with specific role is allowed to use a view?
If I impersonate someone with the admin or itil role, I can still use that view.
Regards,
Inoue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2021 08:47 PM
With Admin yes, you will be able to see the View but not with ITIL.
After following above steps, custom view will only be visible to the user with custom role:
Navigate to a List and then click on the Ham Burger sign to see the view by impersonating with the required user as shown below:
Now impersonate with any other user who does not have this role, the view should not be visible.
Let me know in case you are facing an issue here. Sharing screenshot of your configuration will help further in assisting you.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2021 09:29 PM
Thanks for reply.
The following figure shows a view created as an administrator.
The following figure shows the view of the list of incidents when a user with the Itil role logs in.
The following figure shows the view of the list of incidents when a user with the Itil role logs in.
For some reason, Ex_view is included in the View, even though this user only has the Itil role.
Thank you so much.
Regards,
Inoue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2021 10:58 PM
Okay got It. Then please try with the approach suggested below:
You can use a script to control the form view used by different roles.
Name: Restrict View by Role
Type: System UI > View Rules
Table: Any
Description: Generally the view used on a form is controlled by either specifying the sysparm_view parameter in the url or module properties, or by inheriting the view from the previous form or list. Sometimes this does not apply, such as when opening a referenced field form from a record producer. In this case, you may want to control the view of the form based on roles. This script assumes there is a view called ess available to the current table.
- view - A string containing the name of the current view.
- is_list - A Boolean value indicating whether this is a list view.
Script:
(function overrideView(view, is_list) { //Force non-itil users to use the ess view if (gs.hasRole("itil")) {return;} if (view.startsWith("ess")) {return;} // do not change view if it starts with sys_ (e.g. sys_ref_list) if (view.startsWith("sys_")) {return;} answer = "ess"; // set the new view to answer })(view, is_list);
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke