
- 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
‎02-06-2019 11:00 AM
gs.getUser().isMemberOf(current.assignment_group)// this will return true if the current user is member of group, false when the use is not a member of group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 01:15 AM
Sure, here is my script include that I created a Dynamic filter to.
function notInMySpecificGroups(){ //var sw = new GlideStopWatch(); var isAdmin = gs.hasRole('admin'); // gs.log('( ' + gs.getUserName() + ') ' isAdmin: ' + isAdmin); if (isAdmin) { // do nothing // gs.log ('SKIP LOGIC ( ' + gs.getUserName() + ' ) ' ); } else { var gr = new GlideRecord('sys_user_grmember'); gr.addQuery("user", '!=',gs.getUserID()); gr.addQuery("group.active", true); gr.query(); var array = []; while (gr.next()) { array.push(gr.getValue('group')); } return array; } }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2019 06:02 PM
Thanks for the response on this one, didn't follow this thread for long. Even I had ended up using Dynamic Filter for the requirement.
Kind regards,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2017 11:27 PM
Maybe i can contribute alittle here as well.
I think i have made this work:
var url = gs.action.getGlideURI().getMap();
var sysId = url.get('sys_id');
var gr = new GlideRecord('change_request');
if (gs.getUser().getRecord().getValue('u_type') == '10') {
answer = 'portal';
}else{
if (gr.get(sysId)) {
if (gr.type == '0') {
answer = '';
}else if(gr.type == '1'){
answer = 'emergencyChange';
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 06:32 PM
Hi,
Can you explain this codes:
if (gs.getUser().getRecord().getValue('u_type') == '10')
and
(gr.type == '0')
Thanks.