
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2016 02:32 AM
Hi Everyone,
I am trying to create a view rule using the Advanced Option.
The requirement is to set the rule if the person is member of the assignment group, or is having some particular role.
But, the 'current' object is not available in the view rule scope. There is no proper documentation / example available for view rule script.
Any suggestions, how it can be configured / any other object that can be used within view rule scope.
Thanks,
Manish
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2017 12:57 AM
Manish, late answer, but since the tread has been alive this year, I would like to share my five cents on this.
I had the same challenge, realized that current.xx is not available for use in advanced mode (even though the fields can be chosen from the field chooser to the right of the script field ).
To get around this I used the condition builder to use a Dynamic Filter (built a new one), from that dynamic filter I called a script include that checks for groups that the user belongs to (or not, in my case), thereby directing to two different views, depending on whether the user should see certain fields or not. In my case I wanted to hide the Activity history completely, but give the user write rights to the work notes field.
//Per

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2016 03:34 AM
Hi Aleksandar,
No, the script is not executed client side. It is evaluated at server side, then view gets set.
I am able to use gs.log(), gs.addInfoMessage(), and other GlideSystem methods in the script.
Thanks,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2017 12:32 AM
I logged this with hi as I was hoping to manipulate views based on the current object too but was advised that this is not possible here. Weird that the Simple options do look at current object but the Advanced options don't.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 04:18 AM
Any reply from Hi?
I need to check both the type of change and role of the user to set the view, which I haven't found a way to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 04:23 AM
Yes, but the reply was to log a feature request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2017 04:16 AM
I was told to test using Navigation handlers ( sys_navigator_list.do ) and the following script:
gs.log('Navigation handler triggered on: ' + g_uri.get('sys_id'));
var gr = new GlideRecord('change_request');
if (!gs.hasRole('admin')) {
if (gr.get(g_uri.get('sys_id'))) {
if (gr.type == 'normal') {
gs.log('Change request type is Normal - forcing view to Routine');
g_uri.set('sysparm_view', 'routine');
answer = g_uri.toString('change_request.do'); }
}}
This is entirely copied from Hi's response, which is why it uses gs.log and the wrong Change view names.
I have not had the opportunity to test it myself as my dev instance at the moment can't display forms after too much meddling with views. As I have a planned release this weekend and cloning next week, I won't spend too much time on this until after cloning, but thought it might help you.