- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2015 02:33 PM
Hello Community,
I'm working on a form and I'm interesting in creating different views depending on who is viewing the form. I've managed to create a view but it's not giving me the functionality I'd hoped for.
To create the view, I right-clicked the banner > personalize > Form Layout and created the new view(test_view);
I am aware of the 'View Rules' that should determine when to enforce the view. The problem with this is that the View Rules don't allow for Scripted conditions. That's what I am looking for. I need to modify the view of the form based on role. I thought I had gotten lucky when I saw the 'Roles' option on the UI View form but that didn't appear to do anything.
I have tried using an onLoad Client Script to determine the view as well. If the view is NOT already set for 'test_view', this value comes back null. How could I use this to change the view if it is null? I've tried using the switchView() function which has terrible performance but actually does work.
function onLoad() {
//Type appropriate comment here, and begin script below
var thisView = document.getElementById('sysparm_view').value;
alert("Current View: " + thisView);
}
I have also tried a 'Display' Business Rule with the GlideTransaction method..
var transaction = GlideTransaction.get();
var ViewName = transaction.getRequestParameter("sysparm_view");
gs.log(ViewName);
This produced the same results as the client script. If the view is already set as 'test_view', it returns that value. Otherwise, it returns null. I'm guessing the 'default' view doesn't have a value? I also tried using the getPageName() function i found in another post but that did nothing.
My goal is to change the view of the form(and list view if possible) based on the current logged in user having a certain role. Any help is greatly appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2015 08:44 AM
Hey Kenneth,
This format is the replacement for the global business rule. One thing to note is that your script include name has to be identical to your function name.
Use Script Includes Instead of Global Business Rules
I tested this on a Eureka instance but it should work on previous versions. I hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2015 08:19 AM
on a different thought, if you are segregating based on user's roles or any other field then you can use the "show related fields" in the condition part...eg
<opened.roles>< IS ><admin>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2015 08:26 AM
Surprisingly that does allow me to alter the view. That hasn't worked for me in the past but we did just update our instance. Thats good. However, I need to alter the view based on the current logged in user.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2015 08:44 AM
Hey Kenneth,
This format is the replacement for the global business rule. One thing to note is that your script include name has to be identical to your function name.
Use Script Includes Instead of Global Business Rules
I tested this on a Eureka instance but it should work on previous versions. I hope that helps.