Dynamic View for CMDB Tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 11:18 AM
I'm trying to create a POC for a view rule on our CMDB tables as we have an ask to lock down things based on a custom role we have created called "u_cmdb_privileged".
If a user has this role or the admin role, I want the form to automatically set the view to the "Privileged" view, which has all of the information. Otherwise, the view should automatically be set to the "General" view, which has less information.
This is the view rule script I've created:
//If a user has "u_cmdb_privileged", set their view to Privileged.
//Otherwise, user should be forced to General view.
if (gs.hasRole("u_cmdb_privileged") || gs.hasRole("admin")) {
answer = "Privileged";
} else {
answer = "General";
}
(view);
It doesn't seem as though the above is actually accomplishing anything when the form is launched, and it just lands in the last view that I was using. I'm testing this with a standard non-admin, non-privileged user which should cause the form to load in the 'General' view.
Does it have to do with the fact that I do not have an accompanying list view?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 01:46 AM
To have this view rule working you need to use the internal names of the views that should load, e.g. "default" or "cmdb_browse"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 08:56 AM
The names of the views are just "privileged" and "general", I'm assuming you mean the name that is in the "Name" field and not the "Title" field? I double checked to confirm and was able to confirm that I am using that Name field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 11:32 PM