- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 02:51 AM
Hello All,
In our scenario we have created a list of tasks and all the tasks are assigned to some assignment groups.
If the user is from ABC group and when he tries to open a task (which is assigned to another group) from a list of tasks in requested item then all the fields of that task should be read only and an alert message has to be shown that you don't have access to this task.
how can we achieve the above scenario?
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 02:53 AM
Hi Moulik,
ACL's is the best way to achieve this. You can restrict the write access to the table. Here is the script section you can use.
answer= checkIfMember();
function checkIfMember()
{
var current_user= gs.getUser();
return current_user.isMemberOf(current.assignment_group.name);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 04:32 AM
First option I would prefer is ACL. If not the other way is client script+GlideAjax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 04:44 AM
Thanks for your assistance ,
can you please help me in getting it using a client script .
I am using g_user.userName to get the current user
how to get the groups for the current logged in user so that we can restrict him from viewing the tasks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 04:50 AM
HI Moulik,
Any reason why you don't want to go with ACL.
However you can return true or false from script include and then use the script pasted by Alex below.
So basically you can pass the current group from client script and then at the server side check if user is a member of the group or not.
Getting a User Object - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 03:21 AM
Hi Moulik,
write a script include and check whether the login person belongs to current assignment group and return some string from script include.
if(return string == 'yes')
{
var fields = g_form.getEditableFields();
var length = fields.length;
if (fields != null) {
for ( var inc = 0; inc <= length; inc++) {
try {
if (fields[inc] != "" && g_form.getControl(fields[inc]) != null) {
g_form.setMandatory(fields[inc],false);
g_form.setReadonly(fields[inc], true);
}
} catch (ex) {
console.log("Error : " + ex);
}
}
}
alert('you dont have access to this task');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2015 03:22 AM
Hi Alex,
I would recommend the ACL's approach in this case.